KnpPaginator and custom request

I am using KnpPaginatorBundle in my Symfony2 project. When I try to pass my own Doctrine 2 request for the paginator instance, I got an error:

One of listeners must count and slice given target 

Does anyone have an example of the correct implementation of this for some own query?

In the package documentation I see an example ( https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/Resources/doc/custom_pagination_subscribers.md ), but only for the file system, and I don’t know how to translate this into a db request .

You can help?

EDIT

my request:

 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; 

and tables:

 author (id, first_name, last_name) books (id, title, rate, author_id) 
+4
source share
1 answer

Unfortunately, the package does not work with its own queries. The best solution (although it loads a lot of unnecessary lines) is to get the result of the query and split the array of results.

I ran into this problem about five minutes ago, link: https://groups.google.com/forum/#!msg/symfony2/cgYHeKej7jc/y9dHX-qvTU4J

+3
source

All Articles