在我的codeIgniter模型,我将如何使用对重复密钥更新? [英] How would I use ON DUPLICATE KEY UPDATE in my CodeIgniter model?
问题描述
我有一个codeIgniter / PHP模式,我想插入一些数据到数据库中。
I have a CodeIgniter/PHP Model and I want to insert some data into the database.
不过,我在我的原始的SQL查询这组:
However, I have this set in my 'raw' SQL query:
ON DUPLICATE KEY UPDATE duplicate=duplicate+1
我使用codeIgniter和我将我所有的previous在控制器的SQL查询为的ActiveRecord 。有没有办法从ActiveRecord的基础模型内做到这一点?
I am using CodeIgniter and am converting all my previous in-controller SQL queries to ActiveRecord. Is there any way to do this from within the ActiveRecord-based model?
谢谢!
杰克
推荐答案
该脚本是pretty的俏皮: 的http://web.archive.org/web/20090221091226/http://$c$cigniter.com/forums/viewthread/80958/
This script is pretty nifty: http://web.archive.org/web/20090221091226/http://codeigniter.com/forums/viewthread/80958/
(试行一个在最底层,还没有尝试过自己,但它看起来好了)
(try the one at the very bottom. Haven't tried it myself but it looks alright)
这篇关于在我的codeIgniter模型,我将如何使用对重复密钥更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!