public function actionIndex() { $artistLists = array(); $criteria = new CDbCriteria(); $criteria->addCondition('`on` = 1'); $criteria->order = 'view desc'; $artistLists = ShowArtist::model()->findAll($criteria); $this->render('index'); }
public function actionList() { $artistLists = $category_info = $category_resource_info = array(); $category_id = Yii::app()->request->getParam('category_id', 0); if ($category_id) { $category_info = ShowCategory::model()->find('id =:id', array(':id' => $category_id)); $category_resource_info = ShowResource::model()->find('id =:id', array(':id' => $category_info->source_id)); $artistIds = array(); $criteria = new CDbCriteria(); $criteria->condition = 'category_id =:category_id'; $criteria->params = array(':category_id' => $category_id); $artistRelativeIds = ShowCategoryRelative::model()->findAll($criteria); foreach ($artistRelativeIds as $artistRelativeId) { $artistIds[] = $artistRelativeId->artist_id; } $criteria = new CDbCriteria(); $criteria->addInCondition('id', $artistIds); $criteria->addCondition('`on` = 1'); $criteria->order = 'view desc'; $artistLists = ShowArtist::model()->findAll($criteria); } $this->render('list', array('artistLists' => $artistLists, 'category_info' => $category_info, 'category_resource_info' => $category_resource_info)); }