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


PHP ActiveQuery::all方法代码示例

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


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

示例1: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $countQuery = clone $this->query;
     $pagination = new \yii\data\Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $this->pageSize]);
     $this->query->offset($pagination->offset)->limit($pagination->limit);
     return $this->render("userListBox", ['title' => $this->title, 'users' => $this->query->all(), 'pagination' => $pagination]);
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:10,代码来源:UserListBox.php

示例2: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $result = [];
     $class = $this->relation->modelClass;
     $form = $this->form;
     $template = '<div class="template">' . $this->render($this->viewName, ['model' => new $class(), 'form' => $this->form, 'index' => 'myindex']) . '</div>';
     $items = $this->items ?: $this->relation->all();
     foreach ($items as $index => $model) {
         $result[] = $this->render($this->viewName, compact('index', 'model', 'form'));
     }
     $result[] = Html::a(\Yii::t('app', ' Add'), '#', ['class' => 'btn btn-success glyphicon glyphicon-plus', 'template' => $template, 'onclick' => '
             $(this).before($(this).attr("template").replace(/myindex/g, "new-"+Date.now())); return false;']);
     return implode('', $result);
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:17,代码来源:ArrayModelField.php

示例3: allOfUser

 /**
  * 拿到属于用户的所有,返回数组
  * @param  [type] $userID [description]
  * @param  [type] $db     [description]
  * @return [type]         [description]
  */
 public function allOfUser($userID, $db = null)
 {
     $this->where(['user_id' => $userID]);
     $this->orderBy('price ASC');
     $this->asArray();
     return parent::all($db);
 }
开发者ID:sea129,项目名称:kbay,代码行数:13,代码来源:PackagingPostQuery.php

示例4: fillModels

 protected function fillModels()
 {
     $models = $this->dataProvider ? $this->dataProvider->getModels() : $this->query->all();
     foreach ($models as $model) {
         $this->_models[] = new Model(['instance' => $model, 'standardModel' => $this->_standardModels[0]]);
     }
 }
开发者ID:arogachev,项目名称:yii2-excel,代码行数:7,代码来源:Exporter.php

示例5: allOfProduct

 public function allOfProduct($productID, $db = null)
 {
     $this->where(['product_id' => $productID]);
     $this->indexBy('ebay_account_id');
     $this->asArray();
     return parent::all($db);
 }
开发者ID:sea129,项目名称:kbay,代码行数:7,代码来源:ListingImagesQuery.php

示例6: all

 /**
  * @inheritdoc
  * @return Comment[]|array
  */
 public function all($db = null)
 {
     $result = parent::all($db);
     if (!$this->loadComments) {
         return $result;
     }
     return $this->buildCommentsHierarchy($result);
 }
开发者ID:yeesoft,项目名称:yii2-comments,代码行数:12,代码来源:CommentQuery.php

示例7: allOfEbay

 public function allOfEbay($ebayID, $db = null)
 {
     //$this->select(['*','COUNT(*)']);
     $this->where(['ebay_account_id' => $ebayID]);
     $this->orderBy('updated_at DESC');
     //最新的在第一个
     //$this->asArray();
     return parent::all($db);
 }
开发者ID:sea129,项目名称:kbay,代码行数:9,代码来源:ProductEbayListingQuery.php

示例8: all

 /**
  * @inheritdoc
  */
 public function all($db = null)
 {
     $rows = parent::all($db);
     if (count($rows) > 0 && $this->isMappableQuery()) {
         /** @var ActiveRecord|ActiveRecordTrait $className */
         $className = $this->modelClass;
         $className::addRowsToMap($rows);
     }
     return $rows;
 }
开发者ID:yiister,项目名称:yii2-mappable-ar,代码行数:13,代码来源:ActiveQuery.php

示例9: run

 public function run()
 {
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $this->init();
     $wallEntries = $this->activeQuery->all();
     $output = "";
     $generatedWallEntryIds = array();
     $lastEntryId = "";
     foreach ($wallEntries as $wallEntry) {
         $underlyingObject = $wallEntry->content->getPolymorphicRelation();
         if ($underlyingObject === null) {
             throw new Exception('Could not get contents underlying object!');
         }
         $underlyingObject->populateRelation('content', $wallEntry->content);
         $output .= $this->controller->renderAjax('@humhub/modules/content/views/layouts/wallEntry', ['entry' => $wallEntry, 'user' => $underlyingObject->content->user, 'mode' => $this->mode, 'object' => $underlyingObject, 'content' => $underlyingObject->getWallOut()], true);
         $generatedWallEntryIds[] = $wallEntry->id;
         $lastEntryId = $wallEntry->id;
     }
     return ['output' => $output, 'lastEntryId' => $lastEntryId, 'counter' => count($wallEntries), 'entryIds' => $generatedWallEntryIds];
 }
开发者ID:alefernie,项目名称:intranet,代码行数:20,代码来源:Stream.php

示例10: fetchItemsWithData

 /**
  * This method loads and maps models optionally with additional data-attributes for dropdown-lists. You can use it
  * like this:
  *
  * <code>
  *     <?php
  *         $rateData = DropdownHelper::fetchItemsWithData(Rate::find()->orderTitle(), 'id', 'title', ['currency','per_hour','per_km']);
  *     ?>
  *     <?= $form->field($model, 'rate_id')->dropDownList($rateData['items'], ['prompt'=>Yii::t('app', 'Choose one...'), 'options'=>$rateData['itemOptions']]) ?>
  * </code>
  *
  * @param \yii\db\ActiveQuery $query the prepared query to fetch the data for
  * @param string $from the attribute to map from (usually the id of the model)
  * @param string $to the attribute to map to (usually something like `name`). Note that this can also be a closure
  * with the signature `function ($model)` returning a string
  * @param string[] $dataAttributes list of model attributes which will be loaded as additional `data-XXX` fields
  * for the dropdown-options
  * @return array an array with the keys `items` and `itemOptions`. The first contains the items for the dropdown
  * and second their additional data-options if specified
  */
 public static function fetchItemsWithData($query, $from, $to, $dataAttributes = [])
 {
     /* @var $models \yii\db\ActiveRecord[] */
     //prepare returned vars
     $items = [];
     $itemOptions = [];
     //load data
     $models = $query->all();
     //iterate
     foreach ($models as $model) {
         //item
         $valFrom = $model->{$from};
         $valTo = $to instanceof \Closure ? call_user_func($to, $model) : $model->{$to};
         $items[$valFrom] = $valTo;
         //check if there are item options or continue
         if (empty($dataAttributes)) {
             continue;
         }
         //fetch item options
         $itemOptions[$valFrom] = [];
         foreach ($dataAttributes as $dataAttr) {
             if (!isset($itemOptions[$valFrom]['data'])) {
                 $itemOptions[$valFrom]['data'] = [];
             }
             //prepare
             $parts = explode('.', $dataAttr);
             $identifier = implode('-', $parts);
             //fetch value
             $valOrObj = $model;
             foreach ($parts as $part) {
                 $valOrObj = $valOrObj->{$part};
             }
             //set options
             $itemOptions[$valFrom]['data'][$identifier] = $valOrObj instanceof Object || is_array($valOrObj) ? Json::encode($valOrObj) : $valOrObj;
         }
     }
     //return
     return ['items' => $items, 'itemOptions' => $itemOptions];
 }
开发者ID:asinfotrack,项目名称:yii2-toolbox,代码行数:59,代码来源:DropdownHelper.php

示例11: formattedAll

 public function formattedAll($format, $params, $db = null)
 {
     if (is_string($params)) {
         $params = ['valueColumn' => $params];
     }
     $keyColumn = ArrayHelper::getValue($params, 'keyColumn', 'id');
     $valueColumn = ArrayHelper::getValue($params, 'valueColumn');
     if (!$valueColumn) {
         throw new InvalidConfigException("'valueColumn' must be set if format was choosen.");
     }
     $rows = parent::all($db);
     if ($format === self::DROP_DOWN) {
         return ArrayHelper::map($rows, $keyColumn, $valueColumn);
     }
     if ($format === self::DEP_DROP_AJAX) {
         $output = [];
         foreach ($rows as $row) {
             $output[] = ['id' => $row[$keyColumn], 'name' => $row[$valueColumn]];
         }
         return ['output' => $output, 'selected' => ArrayHelper::getValue($params, 'selected')];
     }
     throw new InvalidConfigException('Invalid format was choosen');
 }
开发者ID:tsyrya,项目名称:mybriop,代码行数:23,代码来源:EntityQuery.php

示例12: all

 /**
  * @inheritdoc
  * @return Progressjobdetail[]|array
  */
 public function all($db = null)
 {
     return parent::all($db);
 }
开发者ID:adem-team,项目名称:advancedgsn,代码行数:8,代码来源:ProgressjobdetailQuery.php

示例13: getWallEntries

 public function getWallEntries()
 {
     return $this->activeQuery->all();
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:4,代码来源:Stream.php

示例14: all

 /**
  * @inheritdoc
  * @return \app\models\activeRecords\Log[]|array
  */
 public function all($db = null)
 {
     $this->orderBy('log_time DESC');
     return parent::all($db);
 }
开发者ID:serj1chen,项目名称:accident_uawebchallenge,代码行数:9,代码来源:LogQuery.php

示例15: allOfCurrentUser

 public function allOfCurrentUser($db = null)
 {
     $this->where(['user_id' => Yii::$app->user->id]);
     return parent::all($db);
 }
开发者ID:sea129,项目名称:kbay,代码行数:5,代码来源:EbayAccountQuery.php


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