Hi everyone,
I'm using the Phalcon\Paginator\Adapter\QueryBuilder to paginate data fetched from a Postgresql database. Everything works as expected, except when I start fuzzing with the page parameter. Lets say there are 15 paginated pages and I start using higher numbers like 16 , 37 , 182 then I get no results. But when I use for example 8365178060 as the pageID then phalcon displays results and the properties before , current and next are -224756533 , -224756532 , -224756531 .
The code I use:
// get paginated page "id" from dispatcher
$page_id = $this->dispatcher->getParam( 'id' , 'int' , null ) ?? 1;
if ( $page_id == 0 )
$page_id = 1;
// build query
$builder = $this->modelsManager->createBuilder()
->columns( [
'w.id' ,
'slug' => 'w.unique_slug' ,
'short_name' => 'upper(w.short_name)' ,
'w.full_name'
] )
->from( [
'w' => 'Websites'
] )
->orderBy( 'w.short_name ASC' );
$paginator = new Phalcon\Paginator\Adapter\QueryBuilder( [
'builder' => $builder ,
'limit' => 10 ,
'page' => $page_id
] );
$pager = $paginator->getPaginate();
if ( count( $pager->items ) == 0 )
exit( 'no results' ); // just for testing
$this->view->setVars( [
'page' => $pager ,
'tags' => $this->getAllTypes()
] );
Did I miss something that would explain this behaviour ? And is there a way around this so that I get the real current pageID ?
Best regards Laurence