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


PHP ActiveQuery::addOrderBy方法代碼示例

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


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

示例1: buildQuery

 /**
  * @param array $attributes
  * @return \yii\db\ActiveQuery
  */
 public function buildQuery($attributes = [])
 {
     $this->setAttributes($attributes);
     if (!empty($this->modelClass) && empty($this->query)) {
         /** @var ActiveRecord $model */
         $model = new $this->modelClass();
         $this->query = $model->find();
     }
     if ($this->validate()) {
         if (!empty($this->query)) {
             $this->filterAttributes();
         }
         if (($sort = $this->getSort()) !== false) {
             $this->query->addOrderBy($sort->getOrders());
         }
         if ($this->whereEnabled && $this->where) {
             $this->query = $this->setWhere($this->query, $this->where);
         }
         return $this->query;
     }
     return null;
 }
開發者ID:platx,項目名稱:yii2-rest,代碼行數:26,代碼來源:SearchForm.php

示例2: prepareQuery

 /**
  *
  * Apply current condition will be applied to a query using this function.
  *
  * @param \yii\db\ActiveQuery $query The query object which current condition must be applied to
  */
 public function prepareQuery($query)
 {
     $field = $this->functionObj->prepareSql();
     if (!$field) {
         return NULL;
     }
     switch ($this->operation) {
         case 'select':
             // Here I need to add property to the target class accroding to alias
             $query->addSelect([$this->alias => $field]);
             break;
         case 'where':
             $query->andWhere($field);
             break;
         case 'group':
             $query->addGroupBy($field);
             break;
         case 'order':
             $query->addOrderBy($field);
             break;
         case 'order_inv':
             $query->addOrderBy([$field => SORT_DESC]);
             break;
     }
 }
開發者ID:VEKsoftware,項目名稱:yii2-report-manager,代碼行數:31,代碼來源:ReportsConditions.php

示例3: sort

 public function sort(ActiveQuery $query)
 {
     $query->addOrderBy('sort DESC');
     return $query;
 }
開發者ID:nanodesu88,項目名稱:yii2-activerecord-enumeration,代碼行數:5,代碼來源:ActiveRecordBehavior.php


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