While using Doctrine in a Symfony project I've come into the situation where I need to apply a condition and then one of two following conditions (which both happen to be sub-queries). I know of the andWhere() and orWhere() functions, but am having trouble using these to generate things like: WHERE cond1 AND ( cond2 OR cond3)
Asked
Active
Viewed 1,811 times
3 Answers
2
You can do this whith DQL:
$models = Doctrine::getTable('ModelName')
->findByDql(
'field_one = ? AND (field_two = ? OR field_three = ?)',
array('cond_1','cond_2', 'cond_3')
);
So $models will be a Doctrine_Collection with all found elements.

DerKlops
- 1,249
- 1
- 12
- 24
0
for the cond2 OR cond3 use wherein
where cond1 and wherein cond2 or wherein cond3
hopefully this gets you started

theraven
- 4,825
- 3
- 20
- 20
-
This seems to help with the subquery part, but doesn't seem to aid in adding the hierarchy to my AND / OR opperators, right? – m14t Nov 02 '09 at 04:26