/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = ClassDescription::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
public function getDescription() { // TODO: also, use the more yii-ish activerecord means of constraining instead of sql joins $found = ClassDescription::model()->findBySql('select class_description.* from class_description where class_id = :cid and language_id = :lid', array('cid' => $this->id, 'lid' => Language::savedLanguageId())); return isset($found) ? $found : ClassDescription::model()->findBySql('select class_description.* from class_description where class_id = :cid and language_id = :lid', array('cid' => $this->id, 'lid' => Language::DEFAULT_LANGUAGE_ID)); }