Welcome Guest, Not a member yet? Register   Sign In
Grouping where conditions using CI and AR
#1

[eluser]dandys997[/eluser]
Hi,
I need to group some clauses using ActiveRecord. For example, I would like to translate this query to ActiveRecord:

Code:
SELECT * FROM test WHERE (key="1" AND key="2" AND key="3") OR (key="4" AND key="5" AND key="6")

Note that there will me more keys inside each group, so I would like to use an associative array to construct them.

It should be something like:

Code:
$this->db->where(array("key" => "1", "key" => "2", "key" => "3"));
$this->db->or_where(array("key" => "4", "key" => "5", "key" => "6"));
$query=$this->db->get("test");

But it doesn't work this way, of course. How can I reach my aim using AR? Thanks in advance for help!




Theme © iAndrew 2016 - Forum software by © MyBB