Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kohana 3 ORM - grouping where conditions with parentheses

I'm trying to run a query through the ORM like this:

   SELECT * from table where (fname like 'string%' or lname like 'string%') 
AND (fname like 'string2%' or lname like 'string2%');

Here's what i have so far:

$results = ORM::factory('profiles');
foreach ($strings as $string) {
    $result->where('fname', 'like', "$string%");
    $result->or_where('lname', 'like', "$string%");
}

But this doesn't account for the parentheses. Any ideas?

like image 799
DexterW Avatar asked Jun 12 '10 14:06

DexterW


1 Answers

Found the answer.

It's done with Kohana's where_open() and where_close() methods.

like image 149
DexterW Avatar answered Oct 18 '22 11:10

DexterW