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


PHP Builder::orderBy方法代码示例

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


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

示例1: doOrdering

 /**
  * Datatable ordering
  *
  * @return null
  */
 private function doOrdering()
 {
     if (array_key_exists('order', $this->input) && count($this->input['order']) > 0) {
         for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) {
             $order_col = (int) $this->input['order'][$i]['column'];
             $order_dir = $this->input['order'][$i]['dir'];
             if ($this->new_version) {
                 $column = $this->input['columns'][$order_col];
                 if ($column['orderable'] == "true") {
                     if (!empty($column['name'])) {
                         $this->query->orderBy($column['name'], $order_dir);
                     } elseif (isset($this->columns[$order_col])) {
                         $column_name = $this->getColumnName($this->columns[$order_col]);
                         $this->query->orderBy($column_name, $order_dir);
                     }
                 }
             } else {
                 if (isset($this->columns[$order_col])) {
                     if ($this->input['columns'][$order_col]['orderable'] == "true") {
                         $column_name = $this->getColumnName($this->columns[$order_col]);
                         $this->query->orderBy($column_name, $order_dir);
                     }
                 }
             }
         }
     }
 }
开发者ID:testoodoo,项目名称:OoodooSiteUp,代码行数:32,代码来源:Datatables.php

示例2: scopeSort

 /**
  * Sort
  *
  * @param \Illuminate\Database\Eloquent\Builder $builder
  * @param string|null                           $sort    Optional sort string
  *
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeSort(Builder $builder, $sort = null)
 {
     if ((is_null($sort) || empty($sort)) && Input::has($this->getSortParameterName())) {
         $sort = Input::get($this->getSortParameterName());
     }
     if (!is_null($sort)) {
         $sort = explode(',', $sort);
         foreach ($sort as $field) {
             $field = trim($field);
             $order = 'asc';
             switch ($field[0]) {
                 case '-':
                     $field = substr($field, 1);
                     $order = 'desc';
                     break;
                 case '+':
                     $field = substr($field, 1);
                     break;
             }
             $field = trim($field);
             if (in_array($field, $this->getSortable())) {
                 $builder->orderBy($field, $order);
             }
         }
     }
 }
开发者ID:classid,项目名称:Database,代码行数:34,代码来源:Sortable.php

示例3: options

 /**
  * Set query options and params
  * @param  array  $options
  * @return Builder
  */
 public function options($options = array())
 {
     // Get order options
     $orderBy = array_get($options, 'order_by', 'created_at');
     $order = array_get($options, 'order', 'desc');
     // Run order
     if ($orderBy == 'rand') {
         $this->query->orderBy(DB::raw('RAND()'), $order);
     } else {
         $this->query->orderBy($orderBy, $order);
     }
     // Also the limit
     if ($limit = array_get($options, 'limit')) {
         $this->defaultLimit = (int) $limit;
     }
     if (is_array($options)) {
         foreach ($options as $key => $value) {
             if (!in_array($key, array('limit', 'order_by'))) {
                 if (is_array($value)) {
                     $this->query->where($key, $value[0], $value[1]);
                 } else {
                     $this->query->where($key, $value);
                 }
             }
         }
     }
     return $this->query;
 }
开发者ID:creolab,项目名称:krustr,代码行数:33,代码来源:DbRepository.php

示例4: scopeOrderByNameAsc

 /**
  * Order by name ascending scope
  *
  * @param Builder $query The current query to append to
  *
  * @return Builder
  */
 public function scopeOrderByNameAsc($query)
 {
     return $query->orderBy('username', 'asc');
 }
开发者ID:nukacode,项目名称:users,代码行数:11,代码来源:User.php

示例5: scopeNewest

 /**
  * Order by created at
  *
  * @param Builder $query
  * @return Builder
  */
 public function scopeNewest($query)
 {
     return $query->orderBy('created_at', 'DESC');
 }
开发者ID:bitsoflove,项目名称:mailstats,代码行数:10,代码来源:MailStatistic.php


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