We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Paginator ( QueryBuilder ) weird behaviour

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

It's most probably an integer overflow error, and I'm betting on it being a PHP issue.

It's possible it can be somehow zephir issue. If could create some zephir code which could possibly reproduce issue then create issue on zephir repository.