fat*_*zzy 6 php activerecord codeigniter
我有这个问题:
$this->db->select("
IF(predicts.predict_owner = votes.vote_user_id , IF(judges.judge_did_accept = 1 , True , False) , 'NotExists' )" , 'user_judgement');
Run Code Online (Sandbox Code Playgroud)
我得到语法错误
`'NotExists'` )
Run Code Online (Sandbox Code Playgroud)
如果我直接在数据库中运行查询,它工作正常...
有没有办法阻止CI自动添加标志?
谢谢
Dan*_* F. 20
您可以使用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);
Run Code Online (Sandbox Code Playgroud)
这将阻止CI添加`
来自用户指南
$ this-> db-> select()接受可选的第二个参数.如果将其设置为FALSE,CodeIgniter将不会尝试使用反引号来保护您的字段或表名称.如果您需要复合选择语句,这非常有用.
PS:我看到你用第二个参数调用select作为"user_judgement",我不确定应该做什么,这不是cay CI希望你使用Active Record
| 归档时间: |
|
| 查看次数: |
15415 次 |
| 最近记录: |