如何用doctrine编写复杂的查询

时间:2015-04-27 13:54:15

标签: symfony doctrine dql

我有一个复杂的查询,我尝试使用queryBuilder转换为doctrine(或者至少在DQL中),但我不管理

select p.* from Pin p where p.id in 
  (select max(p1.id) from Pin p1 where p1.recipe_id not in
     (select p2.recipe_id from Pin p2 where p2.owner_id=2)
   and p1.visibility = 2 
   and p1.recipe_id in (select recipe_id from recipe where category_id in (1,2))

   group by p1.recipe_id )

我尝试在DQL中编写它,但我有一个错误:错误:预期的Doctrine \ ORM \ Query \ Lexer :: T_IN,得到了'。'

select p from Pin p where p.id in 
      (select max(p1.id) from Pin p1 where p1.recipe_id not in
         (select p2.recipe_id from Pin p2 where p2.owner_id=2)
       and p1.visibility = 2 group by p1.recipe_id )
    and p.recette.category in :categories

0 个答案:

没有答案