PHP PDO simple insert or update function

后端 未结 4 1619
不思量自难忘°
不思量自难忘° 2021-01-18 01:23

In trying to create a simple PHP PDO update function that if the field is not found would insert it, I created this little snippet.

function updateorcreate($         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-18 02:03

    try,

        PDO::exec() 
    

    returns 1 if inserted. 2 if the row has been updated.

    for prepared statements,

        PDOStatement::execute() 
    

    You can try,

        PDOStement::rowCount()
    

提交回复
热议问题