_db->select(); $select->from($this->_getPair()) ->limit($count) ->order('RAND()'); return $this->_db->fetchAll($select); } public function getListSelect() { if (null === $this->_select) { $this->_select = parent::getListSelect(); $this->_joinCategory($this->_select); $this->_select->where('`categoryId` = ?', CategoryEntity::ANNUAL) ->order('name'); } return $this->_select; } protected function _joinCategory(Zend_Db_Select $select) { $select->join( $this->_getPair('SponsorCategory', 'sc'), '`sc`.`id` = ' . $this->_quoteField('categoryId'), [] ); } protected function _filter(Zend_Db_Select $select) { $select->where('`sc`.`enabled` = ?', 'y'); return parent::_filter($select); } }