PaginationCore
in package
Table of Contents
Properties
- $limit : int
- $offset : int
- $baseQuery : Join|Builder|null
- $db : string|null
- $parged : array<string|int, mixed>
- $reqData : array<string|int, mixed>
- $table : string
Methods
- __construct() : mixed
- columns() : $this
- Sets the columns to return in the query
- init() : PaginationCore
- paginate() : array<string|int, mixed>|null
- Should be called finally to get the paginated data.
- where() : PaginationCore
- extractPagination() : array<string|int, mixed>
- Picks the pagination data from the request. Pagination data can be defined in the `PAGINATION` key or the `pagination` key.
Properties
$limit
public
int
$limit
= 10
$offset
public
int
$offset
= 0
$baseQuery
private
Join|Builder|null
$baseQuery
= null
$db
private
string|null
$db
= null
$parged
private
array<string|int, mixed>
$parged
= ['columns' => '*', 'where' => []]
$reqData
private
array<string|int, mixed>
$reqData
= []
$table
private
string
$table
Methods
__construct()
public
__construct(array<string|int, mixed>|null $reqData, string $table[, int|null $limit = 10 ][, int|null $offset = 0 ][, string|null $db = 'db' ]) : mixed
Parameters
- $reqData : array<string|int, mixed>|null
- $table : string
- $limit : int|null = 10
- $offset : int|null = 0
- $db : string|null = 'db'
columns()
Sets the columns to return in the query
public
columns([string|array<string|int, mixed> $columns = "*" ]) : $this
Parameters
- $columns : string|array<string|int, mixed> = "*"
Return values
$thisinit()
public
init(callable $callback) : PaginationCore
Parameters
- $callback : callable
Tags
Return values
PaginationCorepaginate()
Should be called finally to get the paginated data.
public
paginate([array<string|int, mixed>|null $where = null ][, array<string|int, mixed>|null $joins = null ]) : array<string|int, mixed>|null
Supports where clause just like the where
method in the Porm query builder
Parameters
- $where : array<string|int, mixed>|null = null
- $joins : array<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed>|nullwhere()
public
where([array<string|int, mixed> $where = [] ]) : PaginationCore
Parameters
- $where : array<string|int, mixed> = []
Return values
PaginationCoreextractPagination()
Picks the pagination data from the request. Pagination data can be defined in the `PAGINATION` key or the `pagination` key.
private
extractPagination() : array<string|int, mixed>
You can also define them in the SEARCH
key or the search
key.
Pagination usually is comprised of the limit
and offset
or LIMIT
and OFFSET
keys.
If none can't be found, it implies the request is new, so the default values are used.