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

后端 未结 7 1520
独厮守ぢ
独厮守ぢ 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 02:52

    you can simply do something like this:

    set unique index on your id

    and then

    try {
       do insert here
    } catch (Exception $e) {
       do update here
    }
    

提交回复
热议问题