Complex WHERE clauses using the PHP Doctrine ORM

后端 未结 7 1916
长发绾君心
长发绾君心 2020-12-13 09:15

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):

7条回答
  •  伪装坚强ぢ
    2020-12-13 09:58

    In my experience, I have sometimes seen a difference between :

    $q->andWhere("(category1 IN $subcategory_in_clause
                OR category2 IN $subcategory_in_clause 
                OR category3 IN $subcategory_in_clause)");
    

    and

    $q->andWhere("(category1 IN $subcategory_in_clause OR category2 IN $subcategory_in_clause OR category3 IN $subcategory_in_clause)");
    

    The first statement is written on 3 lines, the second, on only one. I didn't believe it but THERE IS A DIFFERENCE !

提交回复
热议问题