_getPhotosCountSelect() . ')'); return $columns; } protected function _getFromDbColumns() { return $this->_getFromColumns(); } protected function _getPhotosCountSelect() { $select = $this->_db->select(); $select->from($this->_getPair('Gallery'), 'COUNT(`Gallery`.`id`)'); $select->where('`Gallery`.`idCategory` = `' . $this->_tableAlias . '`.`id`'); return $select; } protected function _getAlbumImageSelect() { $select = $this->_db->select(); $select->from($this->_getPair('Gallery'), 'image'); $select->where('`Gallery`.`idCategory` = `' . $this->_tableAlias . '`.`id`'); $select->where('`Gallery`.`mainImage` = "y"'); $select->order('Gallery.sorter'); $select->limit('1'); return $select; } public function getListSelect() { if (null === $this->_select) { parent::getListSelect(); $this->_select->joinLeft( $this->_getPair('Gallery'), $this->_tableAlias . '.`id` = `Gallery`.`idCategory` AND `Gallery`.`mainImage` = "y"', array('image') ); $this->_select->order('year DESC'); $this->_select->order($this->_tableAlias . '.sorter'); } return $this->_select; } }