本文整理汇总了PHP中CActiveDataProvider::getCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveDataProvider::getCriteria方法的具体用法?PHP CActiveDataProvider::getCriteria怎么用?PHP CActiveDataProvider::getCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveDataProvider
的用法示例。
在下文中一共展示了CActiveDataProvider::getCriteria方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionFindUser
public function actionFindUser($group, $term)
{
$dataProvider = new CActiveDataProvider('User', array('criteria' => array('select' => array('id', 'email')), 'pagination' => array('pageSize' => 500)));
$criteria = $dataProvider->getCriteria();
$criteria->compare('email', $term, true);
$result = CHtml::listData($dataProvider->getData(), 'id', 'email');
$members = Yii::app()->db->createCommand()->select('userid')->from(AuthAssignment::model()->tableName())->where('itemname=:group', array(':group' => $group))->queryColumn();
echo CJSON::encode(array_diff_key($result, array_flip($members)));
Yii::app()->end();
}
示例2: getCriteria
public function getCriteria()
{
$criteria = parent::getCriteria();
$meta = CActiveRecord::model($this->modelClass)->meta();
// if (isset($meta['lang']))
// {
// $criteria->addCondition("lang = '" . Yii::app()->language . "'");
// }
return $criteria;
}
示例3: getCriteria
public function getCriteria()
{
$criteria = parent::getCriteria();
$class = $this->modelClass;
$model = $class::model();
$meta = $model->meta();
if (isset($meta['lang'])) {
$criteria->addCondition("lang = '" . Yii::app()->language . "'");
}
return $criteria;
}
示例4: actionIndex
public function actionIndex()
{
$model = $this->loadModel();
$model->resetScope();
$dataProvider = new CActiveDataProvider($model, array('criteria' => array('with' => array('societe' => array())), 'pagination' => array('pageSize' => 50), 'sort' => array('defaultOrder' => 'societe.name', 'attributes' => array('societe_name' => array('asc' => 'societe.name', 'desc' => 'societe.name DESC'), '*'))));
if (null !== ($formData = Yii::app()->request->getParam(get_class($model)))) {
Yii::app()->session->offsetSet($this->id . '__filter', $formData);
$this->redirect('index');
}
$model->setAttributes(Yii::app()->session->offsetGet($this->id . '__filter', array()));
$criteria = $dataProvider->getCriteria();
foreach ($model->attributes as $attribute => $value) {
if (empty($value)) {
continue;
}
$criteria->compare($attribute, $value);
}
$this->render('index', array('dataProvider' => $dataProvider, 'model' => $model));
}