本文整理汇总了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]);
}
示例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);
}
示例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);
}
示例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]]);
}
}
示例5: allOfProduct
public function allOfProduct($productID, $db = null)
{
$this->where(['product_id' => $productID]);
$this->indexBy('ebay_account_id');
$this->asArray();
return parent::all($db);
}
示例6: all
/**
* @inheritdoc
* @return Comment[]|array
*/
public function all($db = null)
{
$result = parent::all($db);
if (!$this->loadComments) {
return $result;
}
return $this->buildCommentsHierarchy($result);
}
示例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);
}
示例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;
}
示例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];
}
示例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];
}
示例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');
}
示例12: all
/**
* @inheritdoc
* @return Progressjobdetail[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
示例13: getWallEntries
public function getWallEntries()
{
return $this->activeQuery->all();
}
示例14: all
/**
* @inheritdoc
* @return \app\models\activeRecords\Log[]|array
*/
public function all($db = null)
{
$this->orderBy('log_time DESC');
return parent::all($db);
}
示例15: allOfCurrentUser
public function allOfCurrentUser($db = null)
{
$this->where(['user_id' => Yii::$app->user->id]);
return parent::all($db);
}