redtamo 发表于 2009-9-28 15:33:29

关于CI的数据库update

各位大侠,小弟求助ing
直接写sql中可以写 update table set p_num = p_num+3 where id=1000
用CI周末写p_num=p_num+3啊
大侠们,紧急求助啊跪求解法,先取出p_num加3再update就不用说了
使用$this->db->query(sql)的方式不支持数据表的前缀,这样改了数据表的前缀还得改sql.

visvoy 发表于 2009-9-28 16:01:52

->db->set('p_num','p_num+3',false);

redtamo 发表于 2009-9-28 17:30:59

楼上能在具体点吗?
我是太明白用法

visvoy 发表于 2009-9-28 18:44:56

$this->db->set('p_num','p_num+3',false);

oomengnan 发表于 2015-9-1 11:52:18

我的代码是
$this->db->set('show', 'show+1', FALSE);
$this->db->where('id', $id);
$this->db->update($this->_table_name);


但是页面报错了
Error Number: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'show = show+1 WHERE `id` = '1'' at line 1UPDATE `link` SET show = show+1 WHERE `id` = '1'Filename: D:/www/sscms/application/models/link_m.phpLine Number: 14
页: [1]
查看完整版本: 关于CI的数据库update