PHP Класс LessQL\Result

SELECT {* | select_expr, ...} FROM table [WHERE condition [AND condition [...]]] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT count [OFFSET offset]] TODO Add more SQL dialect specifics like FETCH FIRST, TOP etc.
Наследование: implements IteratorAggregate, implements JsonSerializable
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_cache array
$db Database
$globalRows null | lessql\Row[]
$key null | string
$limitCount null | integer
$limitOffset null | integer
$orderBy array
$parentKey null | string
$parent_ null | Result | lessql\Row
$rows null | lessql\Row[]
$select null | string
$single null | boolean
$table string
$where array
$whereParams array

Открытые методы

Метод Описание
__call ( string $name, array $args ) : mixed Get referenced row(s) by name. Suffix "List" gets many rows Arguments are passed to where( $where, $params )
__clone ( )
__construct ( Database | Result | lessql\Row $parent, string $name ) Constructor Use $db->createResult( $parent, $name ) instead
aggregate ( string $function ) : mixed Execute aggregate function and return value
count ( string $expr = "*" ) : integer Count number of rows Implements Countable
createRow ( array $data = [] ) : lessql\Row Create a Row for this result's table The row is bound to this result
delete ( ) : PDOStatement Delete all rows matched by this result
execute ( ) Execute the select query defined by this result.
fetch ( ) : lessql\Row Fetch the next row in this result
fetchAll ( ) : lessql\Row[] Fetch all rows in this result
getCache ( string $key ) : null | mixed Get value from cache
getDatabase ( ) : Database Get the database
getDefinition ( ) : string Get a JSON string defining the SELECT information of this Result Used as identification in caches
getGlobalKeys ( string $key ) : array Get global $key values of the result, i.e., disregarding its parent
getIterator ( ) : ArrayIterator IteratorAggregate
getLocalKeys ( string $key ) : array Get $key values of this result
getParent ( ) : Result | lessql\Row Get parent result or row, if any
getRoot ( ) : Result Get the root result
getTable ( ) : string Get the table of this result
insert ( array $rows, string | null $method = null ) : null | PDOStatement Insert one ore more rows into the table of this result See Database::insert for information on $method
isSingle ( ) : boolean Is this result a single association, i.e. not a list of rows?
jsonSerialize ( ) : lessql\Row[] Implements JsonSerialize
limit ( integer $count, integer | null $offset = null ) Set a result limit and optionally an offset
max ( string $expr ) : string Return maximum value from an expression
min ( string $expr ) : string Return minimum value from an expression
orderBy ( string $column, string $direction = "ASC" ) Add an ORDER BY column and direction
paged ( integer $pageSize, integer $page ) Set a paged limit Pages start at 1
primaryResult ( ) : Result Return a new basic result which selects all rows in this result by primary key
referenced ( string $name, string | array | null $where = null, array $params = [] ) : Result Get referenced row(s) by name. Suffix "List" gets many rows
rowCount ( ) : integer Return number of rows in this result
select ( string $expr ) : Result Return a new result with an additional expression to the SELECT part
setCache ( string $key, mixed $value ) Set cache value
sum ( string $expr ) : string Return sum of values in an expression
update ( array $data ) : null | PDOStatement Update the rows matched by this result, setting $data
via ( string $key ) : Result Create result with new reference key
where ( string | array $condition, string | array $params = [] ) : Result Add a WHERE condition (multiple are combined with AND)
whereNot ( string | array $column, string | array | null $value = null ) Add a "$column is not $value" condition to WHERE (multiple are combined with AND)

Защищенные методы

Метод Описание
getKeys ( lessql\Row[] $rows, string $key ) : array Get $key values of given rows

Описание методов

__call() публичный Метод

Get referenced row(s) by name. Suffix "List" gets many rows Arguments are passed to where( $where, $params )
public __call ( string $name, array $args ) : mixed
$name string
$args array
Результат mixed

__clone() публичный Метод

public __clone ( )

__construct() публичный Метод

Constructor Use $db->createResult( $parent, $name ) instead
public __construct ( Database | Result | lessql\Row $parent, string $name )
$parent Database | Result | lessql\Row
$name string

aggregate() публичный Метод

Execute aggregate function and return value
public aggregate ( string $function ) : mixed
$function string
Результат mixed

count() публичный Метод

Count number of rows Implements Countable
public count ( string $expr = "*" ) : integer
$expr string
Результат integer

createRow() публичный Метод

Create a Row for this result's table The row is bound to this result
public createRow ( array $data = [] ) : lessql\Row
$data array Row data
Результат lessql\Row

delete() публичный Метод

Delete all rows matched by this result
public delete ( ) : PDOStatement
Результат PDOStatement

execute() публичный Метод

Execute the select query defined by this result.
public execute ( )

fetch() публичный Метод

Fetch the next row in this result
public fetch ( ) : lessql\Row
Результат lessql\Row

fetchAll() публичный Метод

Fetch all rows in this result
public fetchAll ( ) : lessql\Row[]
Результат lessql\Row[]

getCache() публичный Метод

Get value from cache
public getCache ( string $key ) : null | mixed
$key string
Результат null | mixed

getDatabase() публичный Метод

Get the database
public getDatabase ( ) : Database
Результат Database

getDefinition() публичный Метод

Get a JSON string defining the SELECT information of this Result Used as identification in caches
public getDefinition ( ) : string
Результат string

getGlobalKeys() публичный Метод

Get global $key values of the result, i.e., disregarding its parent
public getGlobalKeys ( string $key ) : array
$key string
Результат array

getIterator() публичный Метод

IteratorAggregate
public getIterator ( ) : ArrayIterator
Результат ArrayIterator

getKeys() защищенный Метод

Get $key values of given rows
protected getKeys ( lessql\Row[] $rows, string $key ) : array
$rows lessql\Row[]
$key string
Результат array

getLocalKeys() публичный Метод

Get $key values of this result
public getLocalKeys ( string $key ) : array
$key string
Результат array

getParent() публичный Метод

Get parent result or row, if any
public getParent ( ) : Result | lessql\Row
Результат Result | lessql\Row

getRoot() публичный Метод

Get the root result
public getRoot ( ) : Result
Результат Result

getTable() публичный Метод

Get the table of this result
public getTable ( ) : string
Результат string

insert() публичный Метод

Insert one ore more rows into the table of this result See Database::insert for information on $method
public insert ( array $rows, string | null $method = null ) : null | PDOStatement
$rows array
$method string | null
Результат null | PDOStatement

isSingle() публичный Метод

Is this result a single association, i.e. not a list of rows?
public isSingle ( ) : boolean
Результат boolean

jsonSerialize() публичный Метод

Implements JsonSerialize
public jsonSerialize ( ) : lessql\Row[]
Результат lessql\Row[]

limit() публичный Метод

Set a result limit and optionally an offset
public limit ( integer $count, integer | null $offset = null )
$count integer
$offset integer | null

max() публичный Метод

Return maximum value from an expression
public max ( string $expr ) : string
$expr string
Результат string

min() публичный Метод

Return minimum value from an expression
public min ( string $expr ) : string
$expr string
Результат string

orderBy() публичный Метод

Add an ORDER BY column and direction
public orderBy ( string $column, string $direction = "ASC" )
$column string
$direction string

paged() публичный Метод

Set a paged limit Pages start at 1
public paged ( integer $pageSize, integer $page )
$pageSize integer
$page integer

primaryResult() публичный Метод

Return a new basic result which selects all rows in this result by primary key
public primaryResult ( ) : Result
Результат Result

referenced() публичный Метод

Get referenced row(s) by name. Suffix "List" gets many rows
public referenced ( string $name, string | array | null $where = null, array $params = [] ) : Result
$name string
$where string | array | null
$params array
Результат Result

rowCount() публичный Метод

Return number of rows in this result
public rowCount ( ) : integer
Результат integer

select() публичный Метод

Return a new result with an additional expression to the SELECT part
public select ( string $expr ) : Result
$expr string
Результат Result

setCache() публичный Метод

Set cache value
public setCache ( string $key, mixed $value )
$key string
$value mixed

sum() публичный Метод

Return sum of values in an expression
public sum ( string $expr ) : string
$expr string
Результат string

update() публичный Метод

Update the rows matched by this result, setting $data
public update ( array $data ) : null | PDOStatement
$data array
Результат null | PDOStatement

via() публичный Метод

Create result with new reference key
public via ( string $key ) : Result
$key string
Результат Result

where() публичный Метод

Add a WHERE condition (multiple are combined with AND)
public where ( string | array $condition, string | array $params = [] ) : Result
$condition string | array
$params string | array
Результат Result

whereNot() публичный Метод

Add a "$column is not $value" condition to WHERE (multiple are combined with AND)
public whereNot ( string | array $column, string | array | null $value = null )
$column string | array
$value string | array | null

Описание свойств

$_cache защищенное свойство

protected array $_cache
Результат array

$db защищенное свойство

protected Database,lessql $db
Результат Database

$globalRows защищенное свойство

protected null|Row[],lessql $globalRows
Результат null | lessql\Row[]

$key защищенное свойство

protected null|string $key
Результат null | string

$limitCount защищенное свойство

protected null|int $limitCount
Результат null | integer

$limitOffset защищенное свойство

protected null|int $limitOffset
Результат null | integer

$orderBy защищенное свойство

protected array $orderBy
Результат array

$parentKey защищенное свойство

protected null|string $parentKey
Результат null | string

$parent_ защищенное свойство

protected null|Result,lessql|Row,lessql $parent_
Результат null | Result | lessql\Row

$rows защищенное свойство

protected null|Row[],lessql $rows
Результат null | lessql\Row[]

$select защищенное свойство

protected null|string $select
Результат null | string

$single защищенное свойство

protected null|bool $single
Результат null | boolean

$table защищенное свойство

protected string $table
Результат string

$where защищенное свойство

protected array $where
Результат array

$whereParams защищенное свойство

protected array $whereParams
Результат array