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 Phalcon\Paginator\Adapter\Model not support MongoDB collections?

Hi,

I have the following code:

use Phalcon\Paginator\Adapter\Model as Paginator;

// ...

$result = MyCollection::find();

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

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

I thought it would have been neat if this class could handle mutliple types (and in my view I'd still have $page->total_pages, $page->current, $page->before etc). Or, do I neeed to create my own Paginator to handle these dataset?



5.1k

You can check our vegas-cmf/core Mongo adapter for Pagination: https://github.com/vegas-cmf/core/blob/master/src/Paginator/Adapter/Mongo.php Cheers!