BaseCollection
in package
implements
ArrayAccess, IteratorAggregate
A LessQL Collection
Table of Contents
Interfaces
- ArrayAccess
- IteratorAggregate
Constants
- ITEMS_PER_PAGE = 50
Properties
- $className : string
- $items : array<string|int, mixed>
- $lastQueryString : string|null
- $stmt : Result|Row|null
Methods
- __construct() : mixed
- addCondition() : static
- adds condition to collection
- addGroupBy() : static
- addHaving() : static
- addOrder() : static
- adds order to collection
- addSelect() : static
- count() : int
- delete() : static
- fetchAllDbRows() : mixed
- fetchDbRow() : mixed
- getClassName() : string
- returns class name
- getFirst() : mixed
- getItems() : array<string|int, mixed>
- gets collection items
- getIterator() : Traversable|ArrayIterator
- getLastQueryString() : string|null
- hopefully return last executed query
- getSelect() : Result
- get collection select object
- getTableName() : string
- gets collection objects table name
- limit() : static
- limit results
- load() : static
- loads collection items
- map() : array<string|int, mixed>
- maps a callback function to collection items
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- orWhere() : static
- finds elements
- paginate() : array<string|int, mixed>
- return subset of found items (useful for paginate)
- persist() : static
- persists collection items
- remove() : static
- removes collection items
- reset() : static
- resets collection
- save() : static
- where() : static
- finds elements
- getDb() : Database
- gets db service
- interpolateQuery() : string
- Interpolates query with parameters (for debugging only)
Constants
ITEMS_PER_PAGE
public
mixed
ITEMS_PER_PAGE
= 50
Properties
$className
protected
string
$className
$items
protected
array<string|int, mixed>
$items
= []
collection loaded items
$lastQueryString
protected
string|null
$lastQueryString
= null
last executed query string
$stmt
protected
Result|Row|null
$stmt
= null
collection statement
Methods
__construct()
public
__construct(string $className) : mixed
Parameters
- $className : string
addCondition()
adds condition to collection
public
addCondition([array<string|int, mixed>|string|null $condition = [] ][, mixed $whereGroup = 'AND' ]) : static
Parameters
- $condition : array<string|int, mixed>|string|null = []
- $whereGroup : mixed = 'AND'
Return values
staticaddGroupBy()
public
addGroupBy(string $groupBy) : static
Parameters
- $groupBy : string
Return values
staticaddHaving()
public
addHaving(string $having) : static
Parameters
- $having : string
Return values
staticaddOrder()
adds order to collection
public
addOrder([array<string|int, mixed>|string $order = [] ][, string $position = 'end' ]) : static
Parameters
- $order : array<string|int, mixed>|string = []
- $position : string = 'end'
Return values
staticaddSelect()
public
addSelect(string $select) : static
Parameters
- $select : string
Return values
staticcount()
public
count() : int
Return values
intdelete()
public
delete() : static
Return values
staticfetchAllDbRows()
public
fetchAllDbRows() : mixed
fetchDbRow()
public
fetchDbRow() : mixed
getClassName()
returns class name
public
getClassName() : string
Return values
stringgetFirst()
public
getFirst() : mixed
getItems()
gets collection items
public
getItems() : array<string|int, mixed>
Return values
array<string|int, mixed>getIterator()
public
getIterator() : Traversable|ArrayIterator
Return values
Traversable|ArrayIteratorgetLastQueryString()
hopefully return last executed query
public
getLastQueryString() : string|null
Return values
string|nullgetSelect()
get collection select object
public
getSelect() : Result
Return values
ResultgetTableName()
gets collection objects table name
public
getTableName() : string
Return values
stringlimit()
limit results
public
limit(int $page_size[, int $start = 0 ]) : static
Parameters
- $page_size : int
- $start : int = 0
Return values
staticload()
loads collection items
public
load() : static
Return values
staticmap()
maps a callback function to collection items
public
map(callable $callback) : array<string|int, mixed>
Parameters
- $callback : callable
Return values
array<string|int, mixed>offsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
orWhere()
finds elements
public
orWhere(array<string|int, mixed>|string $condition[, array<string|int, mixed> $order = [] ][, int $page_size = null ][, int $start = 0 ]) : static
Parameters
- $condition : array<string|int, mixed>|string
- $order : array<string|int, mixed> = []
- $page_size : int = null
- $start : int = 0
Tags
Return values
staticpaginate()
return subset of found items (useful for paginate)
public
paginate([int $page_size = self::ITEMS_PER_PAGE ]) : array<string|int, mixed>
Parameters
- $page_size : int = self::ITEMS_PER_PAGE
Tags
Return values
array<string|int, mixed>persist()
persists collection items
public
persist([array<string|int, mixed> $persistOptions = [] ]) : static
Parameters
- $persistOptions : array<string|int, mixed> = []
Return values
staticremove()
removes collection items
public
remove() : static
Return values
staticreset()
resets collection
public
reset() : static
Return values
staticsave()
public
save([array<string|int, mixed> $persistOptions = [] ]) : static
Parameters
- $persistOptions : array<string|int, mixed> = []
Return values
staticwhere()
finds elements
public
where(array<string|int, mixed>|string $condition[, array<string|int, mixed> $order = [] ][, int $page_size = null ][, int $start = 0 ]) : static
Parameters
- $condition : array<string|int, mixed>|string
- $order : array<string|int, mixed> = []
- $page_size : int = null
- $start : int = 0
Tags
Return values
staticgetDb()
gets db service
protected
getDb() : Database
Return values
DatabaseinterpolateQuery()
Interpolates query with parameters (for debugging only)
protected
interpolateQuery(string $query, array<string|int, mixed> $params) : string
Parameters
- $query : string
- $params : array<string|int, mixed>