WHERE (a and b) and (c or d)
...
$where = array('condition_a' => '1', // Condition group 0
'condition_b' => '1');
$query->where($where);
$query->andCondition(array('condition_c' => '1'), null, 1); // AND Conjunction should apply between groups
$query->orCondition(array('condition_d' => '1'), null, 1); // OR conjunction should apply within condition group 1 only
...
WHERE ((a and b) or (c or d))
$query->andCondition(array('condition_c' => '1'), null, 1); // AND Conjunction should apply between groups
$query->orCondition(array('condition_d' => '1'), null, 1); // OR conjunction should apply within condition group 1 only
$query->where($where);
WHERE ((c or d) and (a and b))
error_log('cond=' . $criteria->buildConditionalClause($criteria->query['where']));<?php
$query->where(array(
array(
'a' => 1,
'b' => 1
),
array(
'OR:c:=' => 1,
'd' => 1
),
));
$query->andCondition(array('a' => '1')); // First group 0
$query->andCondition(array('b' => '1')); //
$query->andCondition(array('c' => '1'), null, 1); // AND Conjunction should apply between group 0 and 1
$query->orCondition(array('d' => '1'), null, 1); // OR conjunction should apply within condition group 1 onlyThe grouping is a little funky and that lead to the nested array syntax being implemented. IOW, we ran into these issues with the grouping and decided to go another way. I did not deprecate the methods however, so I am totally open to improving/fixing them. FWIW, did you try assigning both sets to groups other than 0?
But what about the use of the andCondition/orCondition calls which also provide the grouping parameter to achieve the same thing? Is andCondition/orCondition with grouping deprecated and should nested where be the preferred way? Shouldn’t below notation yield the same result as your embedded array syntax?
$query->andCondition(array('a' => '1')); // First group 0 $query->andCondition(array('b' => '1')); // $query->andCondition(array('c' => '1'), null, 1); // AND Conjunction should apply between group 0 and 1 $query->orCondition(array('d' => '1'), null, 1); // OR conjunction should apply within condition group 1 only