Files
GestioneSpiaggia.it/library/App/Model/Mongo/PaginatorAdapter.php
T
2021-09-17 12:41:45 +02:00

42 lines
923 B
PHP

<?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());
}
}