protected function unlinkArtistFromAlbums($artistid)
 {
     $sql = "DELETE FROM  artist_album WHERE artist_id=:artist_id";
     $command = Artist::model()->getDbConnection()->createCommand($sql);
     $command->bindValues(array(":artist_id" => $artistid));
     $command->execute();
     return true;
 }
Esempio n. 2
0
 /**
  * 返回基于主键值的数据模型,主键值由 GET 变量提供。
  * 若数据模型没有找到,一个 HTTP 异常被唤起。
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             if (Yii::app()->user->name == "admin") {
                 $condition = '';
             } else {
                 $condition = 'proved=' . Artist::STATUS_PROVED;
             }
             $this->_model = Artist::model()->findbyPk($_GET['id'], $condition);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, '您所请求的页面不存在。');
         }
     }
     return $this->_model;
 }
Esempio n. 3
0
 public function run()
 {
     $model = new Album();
     if (isset($_GET['artist_id'])) {
         $artist_id = $_GET['artist_id'];
         $artist_info = Artist::model()->findByPk($artist_id);
         $model->artist_id = $artist_id;
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Album'])) {
         $model->attributes = $_POST['Album'];
         $model->image = CUploadedFile::getInstance($model, 'image');
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
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.
  * @param integer $id the ID of the model to be loaded
  * @return Artist the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Artist::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 6
0
 protected function afterFind()
 {
     parent::afterFind();
     $this->_tags = $this->_oldTags = ItemsTags::returnTagsString(ItemsTags::ARTIST_TYPE, $this->id);
     Artist::model()->updateCounters(array('click' => 1), 'id=:id', array(':id' => $this->id));
 }