I\'m using the PHP Doctrine ORM to build my queries. However, I can\'t quite seem to figure how to write the following WHERE clause using DQL (Doctrine Query Language):
As it seems like you can't do complex queries using DQL, I wrote the following SQL to pass to the andWhere() method:
$q->andWhere("(category1 IN $subcategory_in_clause
OR category2 IN $subcategory_in_clause
OR category3 IN $subcategory_in_clause) AND TRUE");
Note the "AND TRUE", a hack so that the parser wouldn't ignore the outer parentheses.