Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Juozas

By: a guest on Nov 6th, 2009  |  syntax: PHP  |  size: 0.92 KB  |  hits: 677  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }