alexello / phalcon-mongodb-pagination-adapter

此包已被废弃,不再维护。未建议替代包。

Phalcon 的 MongoDB 分页适配器

v1.0.0 2014-06-05 13:50 UTC

This package is not auto-updated.

Last update: 2022-09-12 21:14:52 UTC


README

Phalcon 的 MongoDB 分页适配器

#使用

// Current page to show
// In a controller this can be:
// $this->request->getQuery('page', 'int'); // GET
// $this->request->getPost('page', 'int'); // POST
$currentPage = (int) $_GET["page"];

// The data set to paginate
$robots = $DB->selectCollection('robots')->find();

// Create a Model paginator, show 10 rows by page starting from $currentPage
$paginator = new \AlexEllo\Phalcon\MongoDB\Pagination\Adapter\MongoCursor(
    array(
        "data" => $robots,
        "limit"=> 10,
        "page" => $currentPage
    )
);

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