コード例 #1
0
 /**
  * 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 = ArtistType::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
コード例 #2
0
ファイル: IndexAction.php プロジェクト: robebeye/MusicDream
 public function run($region = 1, $type = 2)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'proved=:proved';
     $criteria->params = array(':proved' => Artist::STATUS_PROVED);
     $criteria->order = "sort ASC,add_time DESC";
     $criteria->group = 'sort,id';
     $region = (int) $region;
     $type = (int) $type;
     $criteria->addSearchCondition('area_id', $region);
     $criteria->addSearchCondition('type_id', $type);
     $rawData = Artist::model()->findAll($criteria);
     $value = Yii::app()->cache->get('ARTISTS_' . $region . '_' . $type);
     if ($value === false) {
         $dataProvider = new CArrayDataProvider($rawData, array('id' => 'artist', 'pagination' => array('pageSize' => 500)));
         Yii::app()->cache->set('ARTISTS_' . $region . '_' . $type, $dataProvider, 10);
     } else {
         $dataProvider = $value;
     }
     $regionData = ArtistArea::model()->findByPk($region);
     $typeData = ArtistType::model()->findByPk($type);
     $this->render('index', array('dataProvider' => $dataProvider, 'region' => $region, 'type' => $type, 'regionData' => $regionData, 'typeData' => $typeData));
 }