public function run() { /*Top nxb*/ $criteria = new CDbCriteria (); $criteria->limit = 3; $criteria->order = 'frequency desc'; $list = Tacgia::model()->findAll($criteria); $this->render('top_tacgia', array( 'list'=>$list, )); }
public function actionSuggestTags() { if (isset($_GET['q']) && ($keyword = trim($_GET['q'])) !== '') { $tags = Tacgia::model()->suggestTags($keyword); if ($tags !== array()) { echo implode("\n", $tags); } } }
protected function afterSave() { parent::afterSave(); Tacgia::model()->updateFrequency($this->_oldTags, $this->author); }
/** * 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. * @param integer $id the ID of the model to be loaded * @return Tacgia the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Tacgia::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function addTags($tags) { $criteria = new CDbCriteria(); $criteria->addInCondition('name', $tags); $this->updateCounters(array('frequency' => 1), $criteria); foreach ($tags as $name) { if (!$this->exists('name=:name', array(':name' => $name))) { $tag = new Tacgia(); $tag->name = $name; $tag->profile = 'chua co'; $tag->frequency = 1; $tag->save(); } } }