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


PHP Builder::limit方法代码示例

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


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

示例1: parse

 /**
  * Parse the query parameters with the given options.
  * Either for a single dataset or multiple.
  *
  * @param  mixed    $options
  * @param  boolean  $multiple
  * @return void
  */
 public function parse($options, $multiple = false)
 {
     $this->multiple = $multiple;
     if ($multiple) {
         $fullTextSearchColumns = $options;
         //Parse and apply offset using the laravel "offset" function
         if ($offset = $this->getParam('offset')) {
             $offset = intval($offset);
             $this->query->offset($offset);
         }
         //Parse and apply limit using the laravel "limit" function
         if ($limit = $this->getParam('limit')) {
             $limit = intval($limit);
             $this->query->limit($limit);
         }
         //Parse and apply the filters using the different laravel "where" functions
         //Every parameter that has not a predefined functionality gets parsed as a filter
         if ($filterParams = $this->getFilterParams()) {
             $this->parseFilter($filterParams);
         }
         //Parse an apply the fulltext search using the different laravel "where" functions
         //The fulltext search is only applied to the columns passed by $fullTextSearchColumns.
         if ($this->getParam('q') !== false) {
             $this->parseFulltextSearch($this->getParam('q'), $fullTextSearchColumns);
         }
     } else {
         $identification = $options;
         if (is_numeric($identification)) {
             $this->query->where('id', $identification);
         } else {
             if (is_array($identification)) {
                 foreach ($identification as $column => $value) {
                     $this->query->where($column, $value);
                 }
             }
         }
     }
     //Parse and apply field elements using the laravel "select" function
     //The needed fields for the with function (Primary and foreign keys) have to be added accordingly
     if ($fields = $this->getParam('fields')) {
         $this->parseFields($fields);
     }
     //Parse and apply sort elements using the laravel "orderBy" function
     if ($sort = $this->getParam('sort')) {
         $this->parseSort($sort);
     }
     //Parse and apply with elements using the Laravel "with" function
     if (($with = $this->getParam('with')) && $this->isEloquentBuilder) {
         $this->parseWith($with);
     }
     //Parse the config params
     if ($config = $this->getParam('config')) {
         $this->parseConfig($config);
     }
     if ($this->isEloquentBuilder) {
         //Attach the query builder object back to the eloquent builder object
         $this->builder->setQuery($this->query);
     }
 }
开发者ID:marcelgwerder,项目名称:laravel-api-handler,代码行数:67,代码来源:Parser.php

示例2: applyLimit

 /**
  * @param $value
  * @return $this
  */
 public function applyLimit($value)
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('limit', $value);
     $this->model = $this->model->limit($value);
     return $this;
 }
开发者ID:aaronjan,项目名称:housekeeper,代码行数:13,代码来源:Plan.php

示例3: pagination

 /**
  * Возвращает коллекцию в виде пагинации
  *
  * @param int $page
  * @param int $limit
  */
 public function pagination($page, $limit = 10)
 {
     /**
      * @var \Illuminate\Support\Collection $data
      */
     $countTotal = $this->_query->count();
     $this->_query->skip($limit * $page - $limit);
     $this->_query->limit($limit);
     $data = collect();
     foreach ($this->_query->get() as $key => $instance) {
         $_listRow = [];
         foreach ($this->columns->getColumns() as $column) {
             $_listRow[$column->getKey()] = $column->getValues($instance);
         }
         $buttons = $this->filterAction($instance);
         if (count($buttons)) {
             $_listRow = array_merge($_listRow, [GridColumn::ACTION_NAME => implode('', $buttons)]);
         }
         $data->offsetSet($key, $_listRow);
     }
     return new \Illuminate\Pagination\LengthAwarePaginator($data, $countTotal, $limit, $page, ['path' => \Illuminate\Pagination\Paginator::resolveCurrentPath(), 'pageName' => 'page']);
 }
开发者ID:assurrussa,项目名称:grid-view-vue,代码行数:28,代码来源:GridView.php

示例4: limit

 /**
  * Set the "limit" value of the query.
  *
  * @param int $value
  * @return $this 
  * @static 
  */
 public static function limit($value)
 {
     return \Illuminate\Database\Query\Builder::limit($value);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例5: process

 /**
  * @param Builder|EloquentBuilder $src
  * @param OperationInterface|PaginateOperation $operation
  * @return mixed
  */
 public function process($src, OperationInterface $operation)
 {
     $src->limit($operation->getPageSize())->offset($this->getOffset($operation));
     return $src;
 }
开发者ID:view-components,项目名称:eloquent-data-processing,代码行数:10,代码来源:PaginateProcessor.php

示例6: limit

 public function limit($limit)
 {
     $this->original->limit($limit);
     return $this;
 }
开发者ID:wutongwan,项目名称:laravel-lego,代码行数:5,代码来源:EloquentTable.php


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