Wasim A. Wasim A. - 1 year ago 119
PHP Question

Codeigniter WHERE AND OR together

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


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.

Answer Source

Just found solution, if it can help some one.

$this->db->where("id",1)->where("(status='live' OR status='dead')");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download