Cod*_*ium 5 mysql left-join symfony doctrine-orm
我需要限制LEFT JOIN结果,所以我必须使用子查询.有人可以给我建议如何用Doctrine 2做到这一点?
我现在拥有的是:
$qb = $this->_em->createQueryBuilder();
return $qb->add('select', 'c,j')
->add('from', 'JobeetBundle:Category c')
->leftJoin('c.jobs', 'j', 'WITH', 'j.category = c')
->add('where', 'j.expiresAt > ?1')
->add('orderBy','j.expiresAt DESC')
->setParameter(1, new \DateTime())
->getQuery()
->getResult();
Run Code Online (Sandbox Code Playgroud)
但我必须改变它,将每个类别的工作结果限制在10.
不幸的是,这是不可能的。每这里:
https://groups.google.com/forum/#!topic/doctrine-user/0rNbXlD0E_8
您可以在此处使用 IN 来完成此操作:
在 Doctrine 2 中执行 WHERE .. IN 子查询