当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveDataProvider::setKeys方法代码示例

本文整理汇总了PHP中yii\data\ActiveDataProvider::setKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider::setKeys方法的具体用法?PHP ActiveDataProvider::setKeys怎么用?PHP ActiveDataProvider::setKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\data\ActiveDataProvider的用法示例。


在下文中一共展示了ActiveDataProvider::setKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @param bool $unimproved
  *
  * @return ActiveDataProvider
  */
 public function search($params = [], $unimproved = false)
 {
     $query = Release::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params, '');
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'mod_id' => $this->mod_id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['<', 'publish_at', $this->publish_at]);
     $query->andFilterWhere(['like', 'version', $this->version]);
     $query->andFilterWhere(['like', 'file_name', $this->version]);
     if ($unimproved) {
         $models = $dataProvider->getModels();
         $keys = $dataProvider->getKeys();
         $unimproved = $this->mod->getUnimprovedReleases($models);
         foreach ($unimproved as $release) {
             array_unshift($models, $release);
             $keys[] = key($models);
         }
         $dataProvider->setModels($models);
         $dataProvider->setKeys($keys);
     }
     return $dataProvider;
 }
开发者ID:devbrom,项目名称:yii2-releases,代码行数:35,代码来源:SearchRelease.php

示例2: actionIndex

 /**
  * Lists all Column models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Column::find()->alive(), 'pagination' => ['pageSize' => static::MAX_PAGE_SIZE], 'sort' => ['defaultOrder' => ['order' => SORT_ASC]]]);
     //递归处理
     $dataProvider->models = General::recursiveObj($dataProvider->models, 0, 0, '', '<span class="bank"></span>', false);
     $keys = General::getModelsKeys($dataProvider->models, 'id');
     $dataProvider->setKeys($keys);
     // 		fb($keys);
     // 		fb($dataProvider->getKeys());
     // 		fb($dataProvider->models);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
开发者ID:jorry2008,项目名称:turen,代码行数:16,代码来源:ColumnController.php


注:本文中的yii\data\ActiveDataProvider::setKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。