【发布时间】:2013-10-10 21:27:24
【问题描述】:
我正在尝试对使用 DQL 的查询进行分页(因为我将使用一些像 sum 之类的组函数)并且有一个外连接,这里是一个简化的代码:
//in controller
use
Pagerfanta\Pagerfanta,
Pagerfanta\Adapter\DoctrineORMAdapter as PagerAdapter;
//in list action
$query=$em->createQuery(
'select m,sum(d.amount) from
ABundle:Master m
left join ABundle:Detail d with d.master=m
group by m.date'
);
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, true);
$paginator=new Pagerfanta(new PagerAdapter($query));
$paginator->setMaxPerPage($this->getPerPage());
$paginator->setCurrentPage($this->getPage(),false,true);
return $paginator;
问题是我收到以下错误:
An exception has been thrown during the rendering of a template ("Cannot count query which selects two FROM components, cannot make distinction")
我一直在尝试设置一个名为 HINT_CUSTOM_OUTPUT_WALKER 的提示,以便 pagerfanta 将我的查询用作视图并运行它自己的计数,但我无法解决这个问题。
谁能给我一些关于如何正确使用它的指导?
【问题讨论】:
-
仍在研究:github.com/whiteoctober/Pagerfanta/issues/59 当我进行左连接时,这似乎是教义分页器的问题
标签: symfony dql hint pagerfanta