_db->select(); $select->from($this->_getPair('GalleryImage', 'gi'), array('image')); $select->where('`gi`.`productCategoryId` = `g`.`id`'); $select->where('`gi`.`show` = "y"'); $select->order('gi.sorter'); $select->limit('1'); return $select; } public function getAlbumItems($id = null, $count = null) { if (null === $id) { $id = $this->getPrimaryKey(); } $select = $this->_db->select(); $select->from($this->_getPair('GalleryImage', 'gi')); $select->where('`productCategoryId` = ?', $id, Qs_Db::INT_TYPE); $select->where('`show` = "y"'); $select->order('sorter'); if ($count = (int) $count) { $select->limit((int) $count); } return $this->_db->fetchAssoc($select); } protected function _getFromDbSelect($primaryKey) { $select = parent::_getFromDbSelect($primaryKey); $select->where('`g`.`enabled` = "y"'); return $select; } }