Reputation: 343
Like the title says, I'm trying to implement a limit on the results available to be paginated by the KnP Paginator. Setting a limit on my query does nothing, I assume because the paginator sets it's own limit on the query to show the right number of rows per page.
My use case is fairly simple: user applies a few filters in the UI (field must equal X, order by, etc.) and the code translates those to inputs to the query builder. The limit is to allow the user to say 'show me the top 100 entries where [insert condition] is true, ordered by [field]'. Currently does not seem possible with KnP Paginator unless I'm missing something in the documentation.
Upvotes: 0
Views: 2535
Reputation: 5542
Use custom count
query:
<?php
$count = 500;
$query = $entityManager
->createQuery('SELECT a FROM AcmeMainBundle:Article a')
->setHint('knp_paginator.count', $count)
;
$pagination = $paginator->paginate($query, $page, 10);
Upvotes: 0