【发布时间】:2014-08-01 15:28:58
【问题描述】:
我需要实现分页。貌似,Doctrine 不支持某些关节。
这是我的查询:
$query = $this->getEntityManager()
->createQueryBuilder();
$query->setFirstResult(($page - 1) * $maxperpage);
$query->setMaxResults($maxperpage);
$query->select('d')
->from('DemandeBundle:Declaration', 'd')
->orderBy('d.id', 'ASC')
->innerJoin('ContactBundle:Contact', 'c', 'WITH', 'd.contact = c')
->where('c.structure_id = :structure_id')
->setParameter('structure_id', $structureId)
->getQuery()
->getResult();
return new Paginator($query, true);
当我不使用 innerJoin 时它工作正常,但我需要使用它以便只显示与我的用户有关的请求。
使用 innerJoin 我得到了那种错误:
"An exception has been thrown during the rendering of a template
("Cannot count query which selects two FROM components, cannot make distinction") in
DemandeBundle:Demande:listing_demande.html.twig at line 25"
如何在不使用其他捆绑软件或其他任何东西的情况下规避此问题。
希望你能理解我。
【问题讨论】:
标签: php symfony doctrine-orm pagination