Created
March 4, 2013 20:18
-
-
Save romankonz/5085261 to your computer and use it in GitHub Desktop.
DoctrineMongoODMModule Pagination Adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace DoctrineMongoODMModule\Paginator\Adapter; | |
use Zend\Paginator\Adapter\AdapterInterface; | |
class DoctrinePaginator implements AdapterInterface | |
{ | |
protected $query; | |
function __construct(\Doctrine\MongoDB\Query\Builder $query) | |
{ | |
$this->query = $query; | |
} | |
public function count() | |
{ | |
$query = clone $this->query; | |
return $query->count()->getQuery()->execute(); | |
} | |
public function getItems($offset, $itemCountPerPage) | |
{ | |
$query = clone $this->query; | |
$query->skip($offset); | |
$query->limit($itemCountPerPage); | |
return iterator_to_array($query->getQuery()->execute()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment