Answer the question
In order to leave comments, you need to log in
What can this bug in pagination mean?
Good day to all.
I'm trying to organize the output of a list with pagination. I use the plugin https://packagist.org/packages/pagerfanta/pagerfanta. The code looks like this:
public function list($page = 1, $limit = 1)
{
$pager = new Pagerfanta(new DoctrineORMAdapter($this->getDoctrine()
->getRepository(User::class)
->createQueryBuilder('u')
->select('u.id', 'u.username', 'u.email', 'u.isActive')
->orderBy('u.username', 'ASC')));
$pager->setMaxPerPage($limit)->setCurrentPage($page);
dump($pager->getCurrentPageResults());
return $this->render('pages/admin/users/list.html.twig', ['users' => $pager]);
}
dump($pager->getCurrentPageResults());
RuntimeException:
The Paginator does not support Queries which only yield ScalarResults.
Answer the question
In order to leave comments, you need to log in
Use a different adapter like DoctrineDbalAdapter with a little code change.
In your example, a "partial" selection of the object, namely just a few properties of the User class. That is why the result will not be an object, but an array. Pagefanta is telling you exactly that.
Actually, either choose complete objects, or incomplete arrays.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question