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

If i have one million rows in mysql table, how use paginator?

If i have one million rows in mysql table, how use paginator?

Interesting!! I think you need to do the following ;

->nomalize the tables. ->have search functionality in your application. ->Create menu for your data View. The menu can have submenu etc.

Just working on the structure first before getting down to pagination.



5.7k
edited May '15

To use paginator with a resultset that large, you'll want to look here:

https://docs.phalcon.io/en/latest/reference/pagination.html#adapters-usage

Look at the example using "QueryBuilder"

//Passing a querybuilder as data

$builder = $this->modelsManager->createBuilder()
    ->columns('id, name')
    ->from('Robots')
    ->orderBy('name');

$paginator = new PaginatorQueryBuilder(array(
    "builder" => $builder,
    "limit"   => 20,
    "page"    => 1
));

That will query only the results you're looking for on any given page instead of the entire resultlet.