我参与了一个Codeigniter 2 项目,在那里我有一个活跃的记录,比如:$query = $this->db->select_sum('Cardit * GPA', 'sum')
->get('marks_info');它生成如下查询:SELECT SUM(`Cardit` * `GPA`) AS `sum` FROM `marks_info`最近我将我的项目迁移到 Codeigniter 3,但相同的活动记录生成了一些不同的查询,例如:SELECT SUM(`Cardit *` `GPA`) AS `sum` FROM `marks_info`这是错误的,它在 SUM 部分包含 * with Cardit ( 'Cardit *' )。区别:谁能告诉我,我如何在 CodeIgniter 3 中解决这个问题?
2 回答
海绵宝宝撒
TA贡献1809条经验 获得超8个赞
试试这个,它会给你你预期的输出
$query = $this->db->select('sum(Cardit * GPA) sum')->get('marks_info');
慕田峪4524236
TA贡献1875条经验 获得超5个赞
避免查询中的反引号。您可以将false分配给protect_identifiers
like :
$this->db->_protect_identifiers=false;
并相应地运行您的查询。
- 2 回答
- 0 关注
- 260 浏览
添加回答
举报
0/150
提交
取消