Kohana 3 ORM - grouping where conditions with parentheses

Posted by Greelmo on Stack Overflow See other posts from Stack Overflow or by Greelmo
Published on 2010-06-12T14:03:42Z Indexed on 2010/06/12 14:13 UTC
Read the original article Hit count: 353

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about orm