library phalcon-mongodb-pagination-adapter
MongoDB pagination adapter for phalcon
alexello/phalcon-mongodb-pagination-adapter
MongoDB pagination adapter for phalcon
- Thursday, June 5, 2014
- by AlexEllo
- Repository
- 1 Watchers
- 3 Stars
- 15 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 1 Forks
- 1 Open issues
- 2 Versions
- 0 % Grown
MongoDB pagination adapter for phalcon, (*1)
usage
// 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();