代码WHERE和OR在一起 [英] Codeigniter WHERE AND OR together

查看:147
本文介绍了代码WHERE和OR在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过代码合并Where和OR在Codeigniter。

  $ this-> db->其中(id,1); 
$ this-> db-> where(status,live) - > or_where(status,dead);出现的结果是作为查询

其中id =


我需要此查询的结果。

其中id = 1和(status ='live'OR status ='dead');



注意:作为参数从哪里函数。这不适合我的代码。我刚刚简化了我上面的问题。

解决方案

刚刚找到的解决方案,如果它可以帮助一些。

  $ this-> db-> where(id,1) - >其中( 'live'OR status ='dead')); 


I am trying to combine Where And OR in Codeigniter via code.

$this->db->where("id",1);
$this->db->where("status","live")->or_where("status","dead");

Appeared result is as query
where id=1 and status='live' OR status='dead'
Whereas i need result for this query.
where id=1 and (status='live' OR status='dead');

NOTE: Please don't give solution of string passed as parameter from where function. That's not fit into my code. I Just simplified my problem above.

解决方案

Just found solution, if it can help some one.

$this->db->where("id",1)->where("(status='live' OR status='dead')");

这篇关于代码WHERE和OR在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆