Initial Commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see Zend_Paginator_Adapter_Interface
|
||||
*/
|
||||
require_once 'Zend/Paginator/Adapter/Interface.php';
|
||||
|
||||
class App_Model_Mongo_PaginatorAdapter implements Zend_Paginator_Adapter_Interface
|
||||
{
|
||||
|
||||
protected $_cursor = null;
|
||||
|
||||
|
||||
public function __construct(MongoDB\Driver\Cursor $cursor)
|
||||
{
|
||||
$this->_cursor = $cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an cursor limited to items for a page.
|
||||
*
|
||||
* @param integer $offset Page offset
|
||||
* @param integer $itemCountPerPage Number of items per page
|
||||
* @return MongoDB\Driver\Cursor
|
||||
*/
|
||||
public function getItems($offset, $itemCountPerPage)
|
||||
{
|
||||
$cursor = $this->_cursor->skip($offset)->limit($itemCountPerPage);
|
||||
return $cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of rows in the cursor.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->_cursor->toArray());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user