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


PHP Builder::count方法代码示例

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


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

示例1: totalCount

 public function totalCount()
 {
     if ($this->options['distinctCountGroup'] && count($this->originalBuilder->groups) == 1) {
         $this->originalBuilder->groups = null;
     }
     if ($this->options['searchWithAlias']) {
         $cnt = count($this->originalBuilder->get());
     } else {
         $cnt = $this->originalBuilder->count();
     }
     return $cnt;
 }
开发者ID:minkbear,项目名称:datatable,代码行数:12,代码来源:QueryEngine.php

示例2: canFind

 /**
  * @param array $attributes
  * @return bool
  * @throws BadDataQueryException
  */
 public function canFind(array $attributes)
 {
     foreach ($attributes as $key => $value) {
         $this->where($key, $value);
     }
     return $this->model->count() > 0;
 }
开发者ID:crip-laravel,项目名称:core,代码行数:12,代码来源:Repository.php

示例3: count

 /**
  * Count rows
  *
  * @return Integer
  */
 public function count()
 {
     // Save the results from the builder
     $result = $this->builder->count();
     // Reset the builder, just in case we are going to use this repository more then once
     $this->newBuilder();
     return $result;
 }
开发者ID:kodebyraaet,项目名称:pattern,代码行数:13,代码来源:BaseRepository.php

示例4: scopeRandom

 /**
  * Scope a query to only one random item.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeRandom($query)
 {
     $total = $query->count();
     if ($total > 1) {
         $offset = mt_rand(0, $total - 1);
         $query = $query->skip($offset)->take(1);
     }
     return $query;
 }
开发者ID:zsikta,项目名称:laravel-random-model,代码行数:16,代码来源:RandomQueryable.php

示例5: getItems

 public function getItems($limit, $offset)
 {
     $builder = $this->query->getQuery();
     if ($builder->groups || $builder->unions) {
         $row = DB::selectOne("SELECT COUNT(*) qty FROM (" . $this->query->toSql() . ") sub", $this->query->getBindings());
         $total = (int) $row->qty;
     } else {
         $total = $this->query->count();
     }
     $pageOfItems = $this->query->skip($offset)->take($limit)->get();
     return [$pageOfItems, $total];
 }
开发者ID:phonedotcom,项目名称:mason-laravel,代码行数:12,代码来源:EloquentContainer.php

示例6: build

 public function build()
 {
     $request = $this->request;
     $needle = $request->needle();
     if ($needle && $request->searchable) {
         $this->qb->where(function ($subQB) use($needle, $request) {
             foreach ($request->searchable as $column) {
                 $subQB->orWhere($column, 'LIKE', "%{$needle}%");
             }
         });
     }
     $request->modifyQuery($this->qb);
     $this->qb->orderBy($request->orderBy(), $request->sortBy());
     $count = $this->qb->count();
     $this->qb->take($request->perPage());
     $this->qb->offset($request->offset());
     $paginator = new LengthAwarePaginator($request->items($this->qb), $count, $request->perPage(), $request->page());
     $paginator->request = $request;
     $paginator->appends($request->query());
     $this->paginator = $paginator;
 }
开发者ID:ohiocms,项目名称:core,代码行数:21,代码来源:BaseLengthAwarePaginator.php

示例7: 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

示例8: count

 /**
  * @return int
  */
 public function count()
 {
     return $this->specificationQuery->count();
 }
开发者ID:middleout,项目名称:doplio,代码行数:7,代码来源:AbstractRepository.php

示例9: totalCount

 public function totalCount()
 {
     return $this->originalBuilder->count();
 }
开发者ID:CoolGoose,项目名称:Datatable,代码行数:4,代码来源:QueryEngine.php

示例10: count

 /**
  * Get the entry count.
  *
  * @param  array $columns
  * @return int
  */
 public function count(array $columns = ['*'])
 {
     return (new Decorator())->decorate($this->query->count($columns));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:10,代码来源:EloquentCriteria.php

示例11: getItems

 public function getItems($requestedLimit, $requestedOffset)
 {
     $items = $this->collection->slice($requestedOffset, $requestedLimit);
     return [$items, $this->collection->count()];
 }
开发者ID:nhusby,项目名称:mason-laravel,代码行数:5,代码来源:CollectionContainer.php

示例12: count

 /**
  * @return int
  */
 public function count()
 {
     return $this->builder->count();
 }
开发者ID:portonefive,项目名称:tabulator,代码行数:7,代码来源:QueryBuilderHandler.php

示例13: format

 /**
  * Formatting the returned data in an associative array representation of the required datatables response object.
  * @param Builder $originalQuery Original Eloquent query object before applying datatables process, use alt query if aggregate functions are used with the original.
  * @param array $data Returned data collection after processing.
  * @return array Associative array (object) that is required for responding to datatables request.
  */
 public static function format(Builder $originalQuery, $data)
 {
     $recordsTotal = is_null(self::$distinctField) ? $originalQuery->count() : $originalQuery->select(DB::raw('COUNT(DISTINCT ' . self::$distinctField . ') AS total'))->get()->toArray()[0]['total'];
     return ['draw' => Request::input('draw'), 'recordsFiltered' => self::$totalFiltered, 'data' => $data] + compact('recordsTotal');
 }
开发者ID:grey-dev-0,项目名称:laravel-datatables,代码行数:11,代码来源:DataTables.php


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