本文整理匯總了PHP中Objects::getDbCriteria方法的典型用法代碼示例。如果您正苦於以下問題:PHP Objects::getDbCriteria方法的具體用法?PHP Objects::getDbCriteria怎麽用?PHP Objects::getDbCriteria使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Objects
的用法示例。
在下文中一共展示了Objects::getDbCriteria方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionView
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));
}