public function actionView() { $model = $this->_loadModel(Yii::app()->request->getQuery('url')); $cr = new CDbCriteria(); if ($model) { $this->pageTitle = $model->title . ' - Быстрые отзывы покупателей'; $modelFirst = $model; $name = $model->title; $cr->addCondition('t.categorie=' . $model->id); } // $query = Objects::model()->cache(3600); $cr->select = 't.*'; $query = new Objects(null); $query->attachBehaviors($query->behaviors()); $query->applyAttributes($this->activeAttributes)->active(); // ->with('images'); $query->getDbCriteria()->mergeWith($cr); $provider = new CActiveDataProvider($query, array('id' => false, 'pagination' => array('pageSize' => 25))); $provider->sort = Objects::getCSort('t.created_date DESC, t.title'); $itemView = '_objects_view'; $count_items = $provider->totalItemCount; $criteria = new CDbCriteria(); $criteria->scopes = 'active'; $dataProvider = new CActiveDataProvider('Objects', array('criteria' => $criteria, 'sort' => array('defaultOrder' => 't.created_date DESC'), 'pagination' => array('pageSize' => 30))); $sql = 'select count(*) cnt, categorie from objects WHERE objects.status=' . Objects::STATUS_ACTIVE . ' group by categorie'; $connection = Yii::app()->db; $command = $connection->createCommand($sql); $rows = $command->queryAll(); $search = false; $this->render('view', array('provider' => $provider, 'model' => $model, 'itemView' => $itemView, 'per_page' => 25, 'count_items' => $count_items, 'rows' => $rows, 'search' => $search)); }