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

Does find pagination only fetch 10 rows or all rows

Just a quick question

When I use this code:

 $currentPage = (int) $_GET["page"];

    $posts = BlogsPosts::blogPosts($blogid);

    // Create a Model paginator, show 10 rows by page starting from $currentPage
    $paginator = new PaginatorModel(
        array(
            "data"  => $posts,
            "limit" => 10,
            "page"  => $currentPage
        )
    );

    // Get the paginated results
    $posts = $paginator->getPaginate();

Does it then find all rows and then the 10 first or does it "limit 10" in the query, so i dont fetch all the data?

Hope you understand :-)

It adds limit 10 to the query :)

If it would fetch all rows, that would be disasterous for production env, as your database and app setver would crawl :) Basically if you ever developed manual pagination, OFFSET and LIMIT clause in MySQL, that's the purpose of pagination also in this component of PhalconPHP.