_sortByYear($list); } protected function _sortByYear($list) { $categoriesSorted = array(); foreach ($list as $category) { $categoriesSorted[$category['year']][] = $category; } return $categoriesSorted; } public function getListSelect() { $select = parent::getListSelect(); $select->where('`show` = ?', 'y'); $select->having('`photoCount` > ?', 0); return $select; } public function getCategoryItems($id = null) { if (null === $id) { $id = $this->getPrimaryKey(); } $select = $this->_db->select(); $select->from($this->_getPair('Gallery')); $select->where('`idCategory` = ?', $id, \Qs_Db::INT_TYPE); $select->order('sorter'); return $this->_db->fetchAssoc($select); } }