1

I was wondering how to have the first condition constant and only the two bottom conditions as or in codeigniter. It seems to ignore the first condition when the or_where condition is there. How can I specify only the or to apply to the "where private"?

$this->db->where_in('user_id', $followers);

$this->db->where("private", "no");

$this->db->or_where("private", "yes");

Thanks

Matt Ellwood
  • 105
  • 1
  • 13

2 Answers2

2

Unfortunately you can't do that using CodeIgniter's ActiveRecord functions. ActiveRecord doesn't have the capability for brackets around where statements as such.

You can manually write this like so:

$this->db->where('(`private` = "no" OR `private` = "yes")');
Ryan
  • 3,552
  • 1
  • 22
  • 39
2

I think this should do the trick:

$this->db->where("(private='no' OR private='yes' )");
Muhammad Zeeshan
  • 8,722
  • 10
  • 45
  • 55