I make a request through createBuilder()and when it is executed ( getQuery()->execute()->toArray()) I received 10946 . I want to paginate it, so I pass it:
$paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
"builder" => $builder,
"limit" => $limit,
"page" => $current_page
));
$limit 25 and $current_page 1 , but when executed:
$paginator->getPaginate();
$page->total_items;
returns 1 .
Is this a mistake or am I missing something?
UPD: it seems that when counting the elements, it uses the created sql with a limit. It makes no difference what the limit, the limit, divided into paragraphs on the page, is always 1. I could be wrong.
UPD2: a colleague helped me figure this out, the error was in the phalcon: request count()from group bygrouped items. Therefore, the workaround is as follows:
$dataCount = $builder->getQuery()->execute()->count();
$page->next = $page->current + 1;
$page->before = $page->current - 1 > 0 ? $page->current - 1 : 1;
$page->total_items = $dataCount;
$page->total_pages = ceil($dataCount / 100);
$page->last = $page->total_pages;