當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。