PHP PDO simple insert or update function

后端 未结 4 1662
不思量自难忘°
不思量自难忘° 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:27

    If it's mysql-only you could try INSERT INTO ... ON DUPLICATE KEY UPDATE

    http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

提交回复
热议问题