【发布时间】:2018-04-05 02:44:32
【问题描述】:
我尝试使用 codeigniter 活动记录,当我尝试更新名为 Dec 的字段时它给了我错误(之前 1 月 - 11 月很好)...
这是我的代码
$this->db->set($month,"$month+$tax", FALSE);
$this->db->set('total_yearly',"total_yearly+$tax", FALSE);
$this->db->where(array('tax_category' => $tax_category));
$this->db->update($nama_table);
查询返回是这样的
UPDATE `tax` SET Dec = Dec+10000, total_yearly = total_yearly+10000 WHERE `tax_category` = 'Hotel' AND `year` = '2017'
错误信息
您的 SQL 语法有错误;检查手册 对应于您的 MySQL 服务器版本,以便使用正确的语法 'Dec = Dec+2479, total_yearly = total_yearly+2479 附近
tax_category= 'Hotel' AN' 在第 1 行
有什么解决办法吗?我尝试在查询中添加反引号,但结果仍然反引号被删除,或者我没有做好。
谢谢
【问题讨论】:
-
下面的查询对你有用。
-
你可以这样改试试 $this->db->set($month,"'$month+$tax'", FALSE);
-
@itsme,还是不行,查询消息返回 Dec = 'Dec+10000'
标签: php mysql database codeigniter