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