當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CActiveDataProvider::setCriteria方法代碼示例

本文整理匯總了PHP中CActiveDataProvider::setCriteria方法的典型用法代碼示例。如果您正苦於以下問題:PHP CActiveDataProvider::setCriteria方法的具體用法?PHP CActiveDataProvider::setCriteria怎麽用?PHP CActiveDataProvider::setCriteria使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CActiveDataProvider的用法示例。


在下文中一共展示了CActiveDataProvider::setCriteria方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDataProvider

 /**
  *
  * 改進:使用延遲綁定,將這個函數寫在父類裏麵
  *返回某個用戶所發布的所有計劃列表
  * @return CActiveDataProvider $dataProvider  返回CActiveDataProvider對象
  * 使用attach的好處是隨時綁定,不一定在初始化的時候綁定
  */
 public function getDataProvider(CFormModel &$condition)
 {
     $this->attachBehaviors(array('NearScopeBehavior' => array('class' => 'ext.behavior.NearScopeBehavior', 'latitude' => $condition->latitude, 'longitude' => $condition->longitude)));
     $dataProvider = new CActiveDataProvider(Plan::model()->unexpired()->near()->with('user'), array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($this->addCondition($condition));
     return $dataProvider;
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:14,代碼來源:Plan.php

示例2: actionIndex

 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $relationComponent = new RelationComponent();
     $friends = $relationComponent->getfriends();
     $criteria->addInCondition('userId', $friends);
     $criteria->order = 'photoId DESC';
     $dataProvider = new CActiveDataProvider('Photo', array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($criteria);
     $this->page($dataProvider);
     $this->render('index');
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:12,代碼來源:DefaultController.php

示例3: actionAdmin

 public function actionAdmin()
 {
     $title = Yii::app()->request->getParam('title', false);
     $criteria = new CDbCriteria();
     $criteria->order = 'id desc';
     if ($title) {
         $criteria->compare('title', $title, true);
     }
     $dataProvider = new CActiveDataProvider('DreamApp');
     $dataProvider->setCriteria($criteria);
     $this->render('admin', array('title' => $title, 'dataProvider' => $dataProvider));
 }
開發者ID:wpp8909,項目名稱:findzhibo,代碼行數:12,代碼來源:DreamAppController.php

示例4: getList

 /**
  * 返回某個關係的列表。應該按照用戶名的大小寫來排序,但是這裏暫時成了按照注冊日期來排序的!
  * @param  $type  填寫四個:friends,follows,fans,blacks
  * @return CActiveDataProvider  返回CActiveDataProvider對象
  */
 public function getList($type)
 {
     $relationComponent = new RelationComponent();
     $function = 'get' . $type;
     $list = $relationComponent->{$function}();
     $criteria = new CDbCriteria();
     $criteria->addInCondition('t.userId', $list);
     $criteria->order = 't.userId desc';
     $dataProvider = new CActiveDataProvider(User::model(), array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($criteria);
     return $dataProvider;
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:17,代碼來源:Relation.php

示例5: actionAdmin

 public function actionAdmin()
 {
     $type = Yii::app()->request->getParam('type', false);
     $title = Yii::app()->request->getParam('title', false);
     $criteria = new CDbCriteria();
     $criteria->with = 'task';
     $criteria->order = 't.id desc';
     if ($type) {
         $criteria->condition = 'push_type =:push_type';
         $criteria->params = array(':push_type' => $type);
     }
     if ($title) {
         $criteria->compare('task.app_name', $title, true);
     }
     $dataProvider = new CActiveDataProvider('DreamPushTask');
     $dataProvider->setCriteria($criteria);
     $this->render('admin', array('type' => $type, 'title' => $title, 'dataProvider' => $dataProvider));
 }
開發者ID:wpp8909,項目名稱:findzhibo,代碼行數:18,代碼來源:DreamPushTaskController.php

示例6: actionDialogUser

 function actionDialogUser()
 {
     $model = new CActiveDataProvider('User', array('pagination' => array('pageSize' => 20)));
     if (!empty($_POST)) {
         $search = Util::input($_POST['search']);
         $criteria = new CDbCriteria();
         $criteria->compare('user_name', $search, true, 'OR');
         $criteria->compare('user_tel', $search, true, 'OR');
         $model->setCriteria($criteria);
     }
     $this->render('//Dialog/DialogUser', array('model' => $model));
 }
開發者ID:adsavin,項目名稱:air,代碼行數:12,代碼來源:DialogController.php

示例7: actionAdmin

 public function actionAdmin()
 {
     $title = Yii::app()->request->getParam('title', false);
     $criteria = new CDbCriteria();
     $criteria->order = 'id desc';
     if ($title) {
         $criteria->compare('app_name', $title, true);
     } else {
         $criteria->condition = 'show_flag != :show_flag';
         $criteria->params = array(':show_flag' => 0);
     }
     $dataProvider = new CActiveDataProvider('DreamAdPackage');
     $dataProvider->setCriteria($criteria);
     $this->render('admin', array('title' => $title, 'dataProvider' => $dataProvider));
 }
開發者ID:wpp8909,項目名稱:findzhibo,代碼行數:15,代碼來源:DreamAdPackageController.php

示例8: actionRepair

 public function actionRepair()
 {
     $this->checkLogin();
     $params = @$_POST;
     if (!empty($_POST)) {
         // search
         $search = Util::input($_POST['search_code']);
         if (empty($search)) {
             $search = Util::input($_GET['serial_code']);
         }
         // productSerial
         $productSerial = ProductSerial::model()->findByAttributes(array('serial_no' => $search));
         if (!empty($productSerial)) {
             $product = Product::model()->findByAttributes(array('product_code' => $productSerial->product_code));
             $params['product'] = $product;
             $params['productSerial'] = $productSerial;
         }
         // repair history
         $criteria = new CDbCriteria();
         $criteria->compare('serial_no', Util::input($_POST['search_code']));
         $criteria->order = 'repair_id DESC';
         $repairs = new CActiveDataProvider('Repair');
         $repairs->setCriteria($criteria);
         $params['repairs'] = $repairs;
     }
     $this->render('//Basic/Repair', $params);
 }
開發者ID:adsavin,項目名稱:app,代碼行數:27,代碼來源:BasicController.php

示例9: getDataProvider

 /**
  *
  * 改進:使用延遲綁定,將這個函數寫在父類裏麵
  *返回某個用戶所發布的所有計劃列表
  *
  * @return CActiveDataProvider $dataProvider  返回CActiveDataProvider對象
  */
 public function getDataProvider(CFormModel &$condition)
 {
     $dataProvider = new CActiveDataProvider(User::model()->near(), array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($this->addCondition($condition));
     return $dataProvider;
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:13,代碼來源:User.php

示例10: getDataProvider

 /**
  *
  * 改進:使用延遲綁定,將這個函數寫在父類裏麵
  *返回某個用戶所發布的所有計劃列表
  *          主頁默認顯示的是隻在本地的。
  *
  *
  * @return CActiveDataProvider $dataProvider  返回CActiveDataProvider對象
  */
 public function getDataProvider(CFormModel &$condition)
 {
     //      $e=  array_filter($condition->attributes);
     $model = Plan::model()->unexpired()->near();
     if (empty($condition->location)) {
         $model = $model->local()->with(array('user', 'state'));
     } else {
         $model = $model->startThis()->with(array('user', 'state'));
     }
     $model = $model->with(array('user', 'state'));
     $dataProvider = new CActiveDataProvider($model, array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($this->search($condition));
     return $dataProvider;
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:23,代碼來源:Plan.php

示例11: array

                            CHtml::link($data->refersTo->public_id(),
                                    array("useCase/view","id"=>$data->refers_to))
                        : null'), array('class' => 'CDataColumn', 'name' => 'Primary Actor', 'type' => 'html', 'value' => '$data->primaryActor->description'), 'order', array('class' => 'CButtonColumn', 'buttons' => array('view' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/view/$data->primaryKey")'), 'update' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/update/$data->primaryKey")'), 'delete' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/delete/$data->primaryKey")'))))));
echo "<h3>Inlude</h3>";
echo CHtml::link("Add new Event to Include Scenario", array("useCaseEvent/create", "uc" => $model->id_use_case, "cat" => "4"));
$criteria = new CDbCriteria();
$criteria->condition = "use_case = {$model->id_use_case} AND category = 4";
$criteria->order = "`order`";
$events = UseCaseEvent::model()->with('category0', 'useCase', 'primaryActor')->findAll($criteria);
$dataProvider = new CActiveDataProvider('UseCaseEvent', array('pagination' => array('pageSize' => 20)));
$dataProvider->setCriteria($criteria);
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'columns' => array('id_event', array('class' => 'CDataColumn', 'name' => 'category', 'type' => 'html', 'value' => '$data->category0->name'), 'description', array('class' => 'CDataColumn', 'name' => 'Refers To', 'type' => 'html', 'value' => 'isset($data->refersTo) ?
                            CHtml::link($data->refersTo->public_id(),
                                    array("useCase/view","id"=>$data->refers_to))
                        : null'), array('class' => 'CDataColumn', 'name' => 'Primary Actor', 'type' => 'html', 'value' => '$data->primaryActor->description'), 'order', array('class' => 'CButtonColumn', 'buttons' => array('view' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/view/$data->primaryKey")'), 'update' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/update/$data->primaryKey")'), 'delete' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/delete/$data->primaryKey")'))))));
echo "<h3>Alternate</h3>";
echo CHtml::link("Add new Event to Alternate Scenario", array("useCaseEvent/create", "uc" => $model->id_use_case, "cat" => "2"));
$criteria = new CDbCriteria();
$criteria->condition = "use_case = {$model->id_use_case} AND category = 2";
$criteria->order = "`order`";
$events = UseCaseEvent::model()->with('category0', 'useCase', 'primaryActor')->findAll($criteria);
$dataProvider = new CActiveDataProvider('UseCaseEvent', array('pagination' => array('pageSize' => 20)));
$dataProvider->setCriteria($criteria);
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'columns' => array('id_event', array('class' => 'CDataColumn', 'name' => 'category', 'type' => 'html', 'value' => '$data->category0->name'), 'description', array('class' => 'CDataColumn', 'name' => 'Refers To', 'type' => 'html', 'value' => 'isset($data->refersTo) ?
                            CHtml::link($data->refersTo->public_id(),
                                    array("useCase/view","id"=>$data->refers_to))
                        : null'), array('class' => 'CDataColumn', 'name' => 'Primary Actor', 'type' => 'html', 'value' => '$data->primaryActor->description'), 'order', array('class' => 'CButtonColumn', 'buttons' => array('view' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/view/$data->primaryKey")'), 'update' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/update/$data->primaryKey")'), 'delete' => array('url' => '$this->grid->controller->createUrl("/useCaseEvent/delete/$data->primaryKey")'))))));
echo CHtml::image(CHtml::normalizeUrl(array('imagesvg', 'id' => $model->id_use_case)), '');
?>
 
開發者ID:black2279,項目名稱:Tracy-openshift,代碼行數:29,代碼來源:view.php

示例12: actionIndex

 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $dataProvider = new CActiveDataProvider('Pedido');
     if (Yii::app()->user->checkAccess('cliente')) {
         $dataProvider->setCriteria(array('condition' => 'IdCliente=:id', 'params' => array(':id' => Yii::app()->user->id)));
     }
     $this->render('index', array('dataProvider' => $dataProvider));
 }
開發者ID:EPSZ-DAW2,項目名稱:daw2-2014-libreria,代碼行數:11,代碼來源:PedidoController.php


注:本文中的CActiveDataProvider::setCriteria方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。