【发布时间】:2012-06-18 23:07:51
【问题描述】:
我在 Symfony2 项目中使用 KnpPaginatorBundle。当我尝试将 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)
【问题讨论】:
标签: symfony doctrine-orm bundle nativequery knppaginator