Advertisement
Guest User

Juozas

a guest
Nov 6th, 2009
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. class App_Paginator_Adapter_DoctrineQuery implements Zend_Paginator_Adapter_Interface
  4. {
  5.     /**
  6.      * @var Doctrine_Query
  7.      */
  8.     protected $_query;
  9.  
  10.     /**
  11.      * @var int
  12.      */
  13.     protected $_rowCount;
  14.  
  15.     public function __construct(Doctrine_Query $query)
  16.     {
  17.         $this->_query = $query;
  18.     }
  19.  
  20.     /**
  21.      * Get items
  22.      *
  23.      * @param int $offset
  24.      * @param int $itemsPerPage
  25.      * @return Doctrine_Collection
  26.      */
  27.     public function getItems($offset, $itemsPerPage)
  28.     {
  29.         return $this->_query
  30.             ->limit($itemsPerPage)
  31.             ->offset($offset)
  32.             ->execute();
  33.     }
  34.  
  35.     /**
  36.      * Count results
  37.      *
  38.      * @return int
  39.      */
  40.     public function count()
  41.     {
  42.         if ($this->_rowCount === null)
  43.         {
  44.             $this->_rowCount = $this->_query->count();
  45.         }
  46.  
  47.         return $this->_rowCount;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement