Welcome Guest, Not a member yet? Register   Sign In
Active Record question... how to add brackets in query
#1

[eluser]wapatv[/eluser]
Hi!


I want to create a query similar like this with CI Active Record.

A query like this:

Code:
SELECT field1, field2 FROM table WHERE (field1 = 'test' OR field2 = 'test') AND (field1 = 'test2' OR field2 = 'test2');

Notice the brackets that contains the OR comparisons.

How can I add these kind of brackets comparisons to Active Record?

Thanks!
#2

[eluser]danmontgomery[/eluser]
Code:
$query = $this->db->select("field1, field2")->where("(field1 = 'test' OR field2 = 'test')", NULL, FALSE)->where("(field1 = 'test2' OR field2 = 'test2')", NULL, FALSE)->get("table");
#3

[eluser]wapatv[/eluser]
That does the trick... thanks Dan!




Theme © iAndrew 2016 - Forum software by © MyBB