Is there a way to do an “INSERT…ON DUPLICATE KEY UPDATE” in Zend Framework 1.5?

后端 未结 7 1391
独厮守ぢ
独厮守ぢ 2021-01-31 02:25

I would like to use ON DUPLICATE KEY UPDATE in Zend Framework 1.5, is this possible?

Example

INSERT INTO sometable (...)
VALUES (...)
ON DUP         


        
相关标签:
7条回答
  • 2021-01-31 03:00

    As a sidebar, you can simplify the ON DUPLICATE KEY UPDATE clause and reduce the amount of processing your script needs to do by using VALUES():

    $sql = 'INSERT INTO ... ON DUPLICATE KEY UPDATE id = VALUES(id), col2 = VALUES(col2), col3 = VALUES(col3)';
    

    See http://dev.mysql.com/doc/refman/5.1/en/insert-on-duplicate.html for more information.

    0 讨论(0)
提交回复
热议问题