/** * Constructor * * @return void */ public function __construct($data, $modelClassName) { $this->_modelClassName = $modelClassName; if (true === $data instanceof Doctrine_Query) { $this->_cacheKey = sha1($data->getSqlQuery() . serialize($data->getParams())); $cache = Zend_Registry::get('mainCache'); if ($cache->test($this->_cacheKey)) { $this->_loadFromCache($cache); } else { $this->_dbData = $data->execute(); $this->_saveInCache($cache); } } else { $this->_dbData = $data; } $this->_iterator = $this->_dbData->getIterator(); }
/** * Get collection iterator * * @return Iterator */ protected function getIterator() { $query = clone $this->q; $this->_collection = $query->offset($this->offset)->execute(); return $this->_collection->getIterator(); }