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

Maybe Bug in Paginator

Hi,

I just want to list some items paginated. But items of the Page object are always empty but total-items shows the right count! Heres My Code:

        $movies = Movies::find(array(
                    "order" => "createdAt DESC"
                        )
        );

        $paginator = new Paginator(array(
            "data" => $movies,
            "limit" => 10,
            "page" => $numberPage
        ));

        $this->view->page = $paginator->getPaginate();

In the View i just got:

    object(stdClass)[85]
          public 'items' => 
            array (size=0)
              empty
          public 'next' => int 1
          public 'first' => int 1
          public 'before' => int 1
          public 'current' => int 0
          public 'last' => int 7
          public 'total_pages' => int 7
          public 'total_items' => int 63

I've done it similiar to the Docs but it don't works?

Thanks for help.



125.8k
Accepted
answer

You're on page zero, but it looks like the page numbers start at 1. Make sure $numberPage is always between 1 and total_pages.

It's soled! Pagenum must bi bigger then 0 !