我在我的KnpPaginatorBundle项目中使用Symfony2。当我试图将Doctrine 2原生查询传递给分页器实例时,我得到了错误:
One of listeners must count and slice given target对于某些本机查询,有人有正确实现这一点的示例吗?
在bundle的文档中,我看到了示例(https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/Resources/doc/custom_pagination_subscribers.md),但它只适用于文件系统,我不知道如何将其转换为db查询。
你能帮上忙吗?
编辑
我的问题是:
SELECT a.*, highest_rated_book.*
FROM authors a
LEFT JOIN (SELECT * FROM books b ORDER BY b.rate DESC) AS highest_rated_book
ON a.id = highest_rated_book.author_id
GROUP BY highest_rated_book.author_id
ORDER BY a.id;和表格:
author (id, first_name, last_name)
books (id, title, rate, author_id)发布于 2012-06-24 01:12:57
不幸的是,包不适用于本机查询。最好的解决方案(尽管它加载了许多不需要的行)是从查询中获取结果并对结果数组进行分页。
大约五分钟前我遇到了这个问题,参考:https://groups.google.com/forum/#!msg/symfony2/cgYHeKej7jc/y9dHX-qvTU4J
https://stackoverflow.com/questions/11058130
复制相似问题