Nested PHQL Query Conditions with Query Builder

Is there a way to nest/group conditions with the OO PHQL query builder?

Say in raw SQL you have SELECT id, name FROM table WHERE (id = 1 AND name = 2) OR (id = 1 AND name = 3)

With the query builder $queryObj->from('table') ->columns(array('id','name')) ->where('id = 1') ->andWhere('name = 2') ->orWhere(...) // nesting/grouping breaks down/un-expected nesting after this point



9.0k

Try specifying more than one condition within a single where block:

$queryObj->from('table') 
   ->columns(array('id','name'))
   ->where('id = 1 AND xx = 2')
   ->orWhere('id = 2 AND xx = 1');