This is my problem: MySQL "Or" Condition
The solution is to group the OR statements, but i'm using CodeIgniters Active Record. Is there a way to group OR statements using Active Record? Or do I have to write the query myself?
I'm using $this->db->where()
with $this->db->or_where()
It writes the query like this:
WHERE title = 'foobar' AND category = 2 OR category = 3
but what I need is:
WHERE title = 'foobar' AND (category = 2 OR category = 3)
I can't do this:
$this->db->where("title = 'foobar' AND (category = 2 OR category = 3)");
because i'm adding ORs using a foreach loop