我正在尝试通过代码在Codeigniter中组合Where And OR。
$this->db->where("id",1);
$this->db->where("status","live")->or_where("status","dead");
出现的结果是查询,
where id=1 and status='live' OR status='dead'
而我需要此查询的结果。
where id=1 and (status='live' OR status='dead');
注意:请不要给出从where函数作为参数传递的字符串的解决方案。那不适合我的代码。我只是在上面简化了我的问题。
刚刚找到的解决方案,如果可以帮助一些人。
$this->db->where("id",1)->where("(status='live' OR status='dead')");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句