本文整理汇总了PHP中Illuminate\Database\Query\Builder::skip方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::skip方法的具体用法?PHP Builder::skip怎么用?PHP Builder::skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::skip方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: simplePaginate
/**
* Get a paginator only supporting simple next and previous links.
*
* This is more efficient on larger data-sets, etc.
*
* @param int $perPage
* @param array $columns
* @return \Illuminate\Pagination\Paginator
*/
public function simplePaginate($perPage = null, $columns = array('*'))
{
$paginator = $this->query->getConnection()->getPaginator();
$page = $paginator->getCurrentPage();
$perPage = $perPage ?: $this->model->getPerPage();
$this->query->skip(($page - 1) * $perPage)->take($perPage + 1);
return $paginator->make($this->get($columns)->all(), $perPage);
}
示例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']);
}
示例4: skip
/**
* Alias to set the "offset" value of the query.
*
* @param int $value
* @return \Illuminate\Database\Query\Builder|static
* @static
*/
public static function skip($value)
{
return \Illuminate\Database\Query\Builder::skip($value);
}
示例5: paging
/**
* Datatable paging
*
* @return null
*/
protected function paging()
{
if (!is_null($this->input['start']) && !is_null($this->input['length']) && $this->input['length'] != -1) {
$this->query->skip($this->input['start'])->take((int) $this->input['length'] > 0 ? $this->input['length'] : 10);
}
}
示例6: addLimitQuery
/**
* Add limit to query builder
* @param \Illuminate\Database\Query\Builder $query object is by reference
*/
protected function addLimitQuery($query)
{
if (isset($this->limit)) {
$query->skip($this->limit['skip'])->take($this->limit['take']);
}
}
示例7: execute
public function execute(Builder $query)
{
$query->skip($this->getValue());
return $query;
}
示例8: paging
/**
* Perform pagination
*
* @return mixed
*/
public function paging()
{
$this->query->skip($this->request->getStart())->take($this->request->getCount());
}
示例9: getQueryColumns
/**
* Return the crud's custom query columns
*
* @param Builder $builder
* @return array
*/
public static function getQueryColumns(Builder $builder)
{
// Get the first result of the query
$resultSet = $builder->skip(0)->take(1)->get();
// Get the first line from the result query
$firstRow = array_shift($resultSet);
// Convert stdClass $firstRow to array
$stdClassVars = get_object_vars($firstRow);
// Return only the column names
return array_keys($stdClassVars);
}
示例10: build
public function build()
{
if (is_string($this->source) && strpos(" ", $this->source) === false) {
//tablename
$this->type = "query";
$this->query = $this->table($this->source);
$this->total_rows = $this->query->count();
} elseif (is_a($this->source, "\\Illuminate\\Database\\Eloquent\\Model") || is_a($this->source, "\\Illuminate\\Database\\Eloquent\\Builder")) {
$this->type = "model";
$this->query = $this->source;
$this->total_rows = $this->query->count();
} elseif (is_array($this->source)) {
$this->type = "array";
$this->total_rows = count($this->source);
}
//exception
//offset and pagination setup/detect
$config = array('cid' => $this->cid, 'total_items' => $this->total_rows, 'items_per_page' => $this->per_page, 'num_links' => round($this->num_links / 2), 'hash' => $this->hash, 'url' => $this->url, 'current_page' => $this->current_page);
$this->pagination = new \Rapyd\Helpers\Pagination($config);
$offset = $this->pagination->offset();
$this->limit($this->per_page, $offset);
//build orderby urls
$this->orderby_uri_asc = $this->app->url->remove('pag' . $this->cid)->remove('reset' . $this->cid)->append('orderby' . $this->cid, array("-field-", "asc"))->get() . $this->hash;
$this->orderby_uri_desc = $this->app->url->remove('pag' . $this->cid)->remove('reset' . $this->cid)->append('orderby' . $this->cid, array("-field-", "desc"))->get() . $this->hash;
//detect orderby
$orderby = $this->app->url->value("orderby" . $this->cid);
if ($orderby) {
$this->orderby_field = $orderby[0];
$this->orderby_direction = $orderby[1];
$this->orderby($this->orderby_field, $this->orderby_direction);
}
//build subset of data
switch ($this->type) {
case "array":
//orderby
if (isset($this->orderby)) {
list($field, $direction) = $this->orderby;
$column = array();
foreach ($this->source as $key => $row) {
$column[$key] = $row[$field];
}
if ($direction == "asc") {
array_multisort($column, SORT_ASC, $this->source);
} else {
array_multisort($column, SORT_DESC, $this->source);
}
}
//limit-offset
if (isset($this->limit)) {
$this->source = array_slice($this->source, $this->limit[1], $this->limit[0]);
}
$this->data = $this->source;
break;
case "query":
case "model":
//orderby
if (isset($this->orderby)) {
$this->query = $this->query->orderBy($this->orderby[0], $this->orderby[1]);
}
//limit-offset
if (isset($this->limit)) {
$this->query = $this->query->skip($this->pagination->offset())->take($this->per_page);
}
$this->data = $this->query->get();
break;
}
return $this;
}