我有这样的查询:
$this->db->select("
IF(predicts.predict_owner = votes.vote_user_id , IF(judges.judge_did_accept = 1 , True , False) , 'NotExists' )" , 'user_judgement');
在
上出现语法错误 `'NotExists'` )
如果我直接在数据库中运行查询,它工作得很好…
有什么方法可以防止CI自动添加'标志?
谢谢
您可以使用FALSE作为最后一个参数来调用select方法,如下所示
$this->db->select("IF(predicts.predict_owner = votes.vote_user_id , IF(judges.judge_did_accept = 1 , True , False) , 'NotExists' ),'user_judgement'",false);
将阻止CI添加'
选自用户指南
$this->db->select()接受第二个可选参数。如果将其设置为FALSE, CodeIgniter将不会尝试保护带有反引号的字段或表名。这在需要复合选择语句时非常有用。
PS:我看到你调用选择与第二个参数为"user_judgement",我不确定应该做什么,这不是一天CI希望你使用活动记录