_joinCategory($select); return $select; } protected function _joinCategory($select) { $select->joinLeft( $this->pairDirectorFileCategory, "`DirectorFileCategory`.`id` = `{$this->_tableAlias}`.`idCategory`", array( 'category' => new Zend_Db_Expr("`DirectorFileCategory`.`title`"), 'categorySorter' => 'sorter' ) ); return $select; } public function getCategories4Select() { if (null === $this->_categories) { $this->_categories = $this->getDirectorFileCategory4Select(); } return $this->_categories; } public function getCategoriesCount() { $select = $this->db->select(); $select->from($this->pair, new Zend_Db_Expr('COUNT(DISTINCT `DirectorFile`.`idCategory`)')); return (int) $this->db->fetchOne($select); } public static function getFile($id) { $db = Qs_Db::getInstance(); $select = $db->select(); $select->from(Qs_Db::getTableName('DirectorFile'), array('file')); $select->where('id = ?', (int) $id, Qs_Db::INT_TYPE); $doc = Zend_Registry::get('doc'); if ($doc instanceof App_Doc_User) { $select->where('enabled = "y"'); } return $db->fetchOne($select); } }