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


PHP Builder::orderBy方法代码示例

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


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

示例1: executeQuery

 /**
  * 주어진 db query를 실행한다.
  *
  * @param Builder            $query      질의
  * @param int|int[]|stdClass $navigation 검색시 사용할 navigation(page, perPage, sort, order) 정보
  *
  * @return array
  */
 protected function executeQuery($query, $navigation = null)
 {
     // set default
     $order = $this->defaultOrder;
     $sort = $this->defaultSort;
     $perPage = $this->defaultPerPage;
     $page = null;
     if (is_array($navigation)) {
         list($page, $perPage) = $navigation;
     } elseif (is_object($navigation)) {
         $page = data_get($navigation, 'page', $page);
         $perPage = data_get($navigation, 'perPage', $perPage);
         $order = data_get($navigation, 'order', $order);
         $sort = data_get($navigation, 'sort', $sort);
     }
     if ($sort !== null) {
         $query->orderBy($sort, $order);
     }
     if ($navigation === null) {
         $collection = $query->get();
     } elseif ($page !== null) {
         $collection = $query->forPage($page, $perPage);
     } else {
         $collection = $query->paginate($perPage);
     }
     return $collection;
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:35,代码来源:DatabaseRepositoryTrait.php

示例2: applyOrderBy

 /**
  * @param string $column
  * @param string $direction
  * @return $this
  */
 public function applyOrderBy($column, $direction = 'asc')
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('order by', [$column, $direction]);
     $this->model = $this->model->orderBy($column, $direction);
     return $this;
 }
开发者ID:aaronjan,项目名称:housekeeper,代码行数:14,代码来源:Plan.php

示例3: order

 /**
  * {@inheritdoc}
  */
 public function order(Builder $builder, $direction)
 {
     if ($this->columnClause !== null) {
         $builder->orderBy($this->columnClause, $direction);
     }
     return $this;
 }
开发者ID:guratr,项目名称:cruddy,代码行数:10,代码来源:Computed.php

示例4: build

 /**
  * flush events, build pagination and sort items
  * 
  * @return $this
  */
 public function build()
 {
     BurpEvent::flush('dataset.sort');
     BurpEvent::flush('dataset.page');
     $this->paginator = Paginator::make($this->total_rows, $this->per_page, $this->page);
     $offset = $this->paginator->offset();
     $this->limit($this->per_page, $offset);
     if (is_array($this->source)) {
         //orderby
         if (isset($this->orderby)) {
             list($field, $direction) = $this->orderby;
             array_orderby($this->source, $field, $direction);
         }
         //limit-offset
         if (isset($this->limit)) {
             $this->source = array_slice($this->source, $this->limit[1], $this->limit[0]);
         }
         $this->data = $this->source;
     } else {
         //orderby
         if (isset($this->orderby)) {
             $this->query = $this->query->orderBy($this->orderby[0], $this->orderby[1]);
         }
         //limit-offset
         if (isset($this->per_page)) {
             $this->query = $this->query->skip($offset)->take($this->per_page);
         }
         $this->data = $this->query->get();
     }
     return $this;
 }
开发者ID:faizan31,项目名称:datagrid,代码行数:36,代码来源:DataSet.php

示例5: execute

 public function execute(Builder $query)
 {
     foreach ($this->getValuesIterator() as $orderBy) {
         $query->orderBy($orderBy->getName(), $orderBy->getValue());
     }
     return $query;
 }
开发者ID:brenodouglas,项目名称:QueryApi,代码行数:7,代码来源:OrderByCollection.php

示例6: orderBy

 /**
  * 
  * @param string $value
  */
 public function orderBy($value = [])
 {
     //if array is not empty
     if (count($value) > 0) {
         $this->query = $this->query->orderBy($value[0], $value[1]);
     }
     return $this;
 }
开发者ID:rekale,项目名称:sikasir,代码行数:12,代码来源:EloquentRepository.php

示例7: orderBy

 /**
  * Order the results by the given column in the given direction.
  *
  * @param string $key
  * @param string $direction
  * @return $this
  * @throws TableNotSetException
  */
 public function orderBy($key, $direction = 'asc')
 {
     if (!$this->query) {
         throw new TableNotSetException("You must set a database table to get results from.");
     }
     $this->query = $this->query->orderBy($key, $direction);
     return $this;
 }
开发者ID:michaeljennings,项目名称:carpenter,代码行数:16,代码来源:Illuminate.php

示例8: setupBasicQueryFilter

 /**
  * Setup basic query string filter to eloquent or query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder  $query
  * @param  array  $input
  *
  * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
  */
 protected function setupBasicQueryFilter($query, array $input = [])
 {
     $orderBy = $this->getBasicQueryOrderBy($input);
     $direction = $this->getBasicQueryDirection($input);
     $columns = isset($input['columns']) ? $input['columns'] : null;
     if (is_array($columns) && $this->isColumnExcludedFromFilterable($orderBy, $columns)) {
         return $query;
     }
     !empty($orderBy) && $query->orderBy($orderBy, $direction);
     return $query;
 }
开发者ID:DavidIWilson,项目名称:site1,代码行数:19,代码来源:QueryFilterTrait.php

示例9: scopeQueryWithParams

 /**
  * A reusable query to pass params
  *
  * @param Builder $query
  * @param array $queryFilter
  *
  * @return Builder
  */
 public function scopeQueryWithParams($query, $queryFilter)
 {
     $limit = isset($queryFilter['limit']) ? $queryFilter['limit'] : 10;
     $perPage = isset($queryFilter['perPage']);
     $orderBy = isset($queryFilter['orderBy']) ? $queryFilter['orderBy'] : 'created_at';
     $sortOrder = isset($queryFilter['sortOrder']) ? $queryFilter['sortOrder'] : 'desc';
     $query->orderBy($orderBy, $sortOrder);
     if ($perPage) {
         return $query->paginate($perPage);
     }
     return $query->take($limit);
 }
开发者ID:lolzballs,项目名称:website,代码行数:20,代码来源:Post.php

示例10: optionAppliedPaginate

 /**
  * @param  \Illuminate\Database\Query\Builder|\Minhbang\Kit\Extensions\Model $query
  * @param bool $position
  *
  * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  */
 protected function optionAppliedPaginate($query, $position = false)
 {
     list($column, $direction) = $this->options->column('sort');
     if ($column) {
         $query->orderBy($column, $direction);
     } else {
         if ($position) {
             $query->orderPosition();
         }
     }
     return $query->paginate($this->options->get('page_size', 6));
 }
开发者ID:minhbang,项目名称:laravel-option,代码行数:18,代码来源:OptionableController.php

示例11: ordering

 /**
  * Datatable ordering
  *
  * @return null
  */
 protected function ordering()
 {
     if (array_key_exists('order', $this->input) && count($this->input['order']) > 0) {
         $columns = $this->cleanColumns($this->aliased_ordered_columns);
         for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) {
             $order_col = (int) $this->input['order'][$i]['column'];
             if (isset($columns[$order_col])) {
                 if ($this->input['columns'][$order_col]['orderable'] == "true") {
                     $this->query->orderBy($columns[$order_col], $this->input['order'][$i]['dir']);
                 }
             }
         }
     }
 }
开发者ID:khaidirh,项目名称:laravel4-datatables-package,代码行数:19,代码来源:Datatables.php

示例12: orderBy

 /**
  * @param array $orders
  * @param string $v 兼容原来的方法
  * @return $this
  */
 public function orderBy($orders = [], $v = 'desc')
 {
     if (empty($orders)) {
         return $this;
     }
     if (is_array($orders)) {
         foreach ($orders as $k => $v) {
             $this->operator->orderBy($k, $v);
         }
     } else {
         $this->operator->orderBy($orders, $v);
     }
     return $this;
 }
开发者ID:kyleing,项目名称:gtbool,代码行数:19,代码来源:DBOperator.php

示例13: getFilteredQueryListRows

 /**
  * Return the filtered, ordered and paginated rows from the crud's custom query
  *
  * @param Builder $query
  * @param int $start
  * @param int $length
  * @param array $filters
  * @param null $order
  * @return array
  */
 public static function getFilteredQueryListRows(Builder $query, $start, $length, $filters = [], $order = null)
 {
     // Get the total count of rows with no filters and pagination
     $countTotal = $query->count();
     // Check if any filters were submitted
     if ($filters) {
         foreach ($filters as $filterName => $filterValue) {
             // Check if there is any filter operator in the field string
             $operation = SQL::findOperationWhere($filterValue);
             $query->where($filterName, $operation['operation'], $operation['text']);
         }
     }
     // Get the total count of rows filtered, but without pagination
     $countFiltered = $query->count();
     // Execute pagination
     $query->skip($start)->take($length);
     // Check if an order by was submitted
     if ($order) {
         $query->orderBy($order['name'], $order['dir']);
     }
     return ['rows' => $query->get(), 'count_filtered' => $countFiltered, 'count_total' => $countTotal];
 }
开发者ID:laravader,项目名称:cms,代码行数:32,代码来源:Queries.php

示例14: addOrderByQuery

 /**
  * Add order by to query builder
  * @param \Illuminate\Database\Query\Builder $query object is by reference
  */
 protected function addOrderByQuery($query)
 {
     if (isset($this->orderBy)) {
         $query->orderBy($this->orderBy['column'], $this->orderBy['direction']);
     } else {
         // Default order by
         if (isset($this->attributes['order_by'])) {
             $query->orderBy($this->attributes('order_by'), $this->attributes('order_by_dir'));
         }
         // Else omit the order by statement completely which will use tables clustered index as order
     }
 }
开发者ID:mreschke,项目名称:repository,代码行数:16,代码来源:DbStore.php

示例15: loadLatest

 /**
  * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  */
 public function loadLatest()
 {
     return $this->productResource->orderBy('updated_at', 'desc')->with(Product::standardRelations())->paginate();
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:7,代码来源:ProductRepository.php


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