PHP Класс Spot\Query

Автор: Vance Lucas ([email protected])
Наследование: implements Countable, implements IteratorAggregate, implements spot\QueryInterface
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_customMethods array Custom methods added by extensions or plugins
$_data array Storage for eager-loaded relations
$_entityName string
$_mapper Mapper
$_noQuote boolean
$_queryBuilder
$_tableName string
$_whereOperatorObjects array Already instantiated operator objects
$_whereOperators array
$with array Storage for query properties

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

Метод Описание
__call ( string $method, array $args ) : mixed Run user-added callback
__construct ( Mapper $mapper ) Constructor Method
addMethod ( string $method, callable $callback ) Add a custom user method via closure or PHP callback
addWhereOperator ( string $operator, callable | string $action ) Adds a custom type to the type map.
andWhere ( array $where, string $type = 'AND' ) WHERE AND conditions
builder ( ) : Doctrine\DBAL\Query\QueryBuilder Get current Doctrine DBAL query builder object
count ( ) : integer SPL Countable function Called automatically when attribute is used in a 'count()' function call
delete ( ) Delete (passthrough to DBAL QueryBuilder)
entityName ( ) : string Get current entity name query is to be performed on
escape ( string $string ) : string Escape/quote direct user input
escapeIdentifier ( string | array $identifier ) : string | array Escape/quote identifier
execute ( ) : mixed Execute and return query as a collection
expr ( ) : Doctrine\DBAL\Query\Expression\ExpressionBuilder Return DBAL Query builder expression
fieldWithAlias ( string $field, boolean $escaped = true ) : string Get field name with table alias appended
first ( ) : mixed Return the first entity matched by the query
from ( ) From (passthrough to DBAL QueryBuilder)
getIterator ( ) : Collection SPL IteratorAggregate function Called automatically when attribute is used in a 'foreach' loop
getParameters ( ) : mixed Get all bound query parameters (passthrough to DBAL QueryBuilder)
group ( array $fields = [] ) GROUP BY clause
having ( array $having, string $type = 'AND' ) Having clause to filter results by a calculated value
jsonSerialize ( ) JsonSerializable
limit ( integer $limit, integer $offset = null ) Limit executed query to specified amount of records Implemented at adapter-level for databases that support it
mapper ( ) : Mapper Get current adapter object
noQuote ( boolean $noQuote = true ) Set field and value quoting on/off - maily used for testing output SQL since quoting is different per platform
offset ( integer $offset ) Offset executed query to skip specified amount of records Implemented at adapter-level for databases that support it
offsetExists ( $key ) SPL - ArrayAccess
offsetGet ( $key ) SPL - ArrayAccess
offsetSet ( $key, $value ) SPL - ArrayAccess
offsetUnset ( $key ) SPL - ArrayAccess
orWhere ( array $where, string $type = 'AND' ) WHERE OR conditions
order ( array $order ) ORDER BY columns
search ( mixed $fields, string $query, array $options = [] ) Search criteria (FULLTEXT, LIKE, or REGEX, depending on storage engine and driver)
select ( ) Select (passthrough to DBAL QueryBuilder)
setParameters ( ) Set query parameters (passthrough to DBAL QueryBuilder)
toArray ( string | null $keyColumn = null, string | null $valueColumn = null ) : array Convenience function passthrough for Collection
toSql ( ) : string Get raw SQL string from built query
unescapeIdentifier ( string $identifier ) : string Removes escape/quote character
where ( array $where, string $type = 'AND' ) WHERE conditions
whereFieldSql ( string $field, string $sql, array $params = [] ) WHERE field + raw SQL
whereSql ( string $sql ) WHERE conditions
with ( mixed | null $relations = null ) Relations to be eager-loaded

Приватные методы

Метод Описание
getWhereOperatorCallable ( string $operator ) : callable | false
parseWhereToSQLFragments ( array $where, boolean $useAlias = true ) : array Parse array-syntax WHERE conditions and translate them to DBAL QueryBuilder syntax

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

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

Run user-added callback
public __call ( string $method, array $args ) : mixed
$method string Method name called
$args array Array of arguments used in missing method call
Результат mixed

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

Constructor Method
public __construct ( Mapper $mapper )
$mapper Mapper

addMethod() публичный статический Метод

Add a custom user method via closure or PHP callback
public static addMethod ( string $method, callable $callback )
$method string Method name to add
$callback callable Callback or closure that will be executed when missing method call matching $method is made

addWhereOperator() публичный статический Метод

Adds a custom type to the type map.
public static addWhereOperator ( string $operator, callable | string $action )
$operator string
$action callable | string

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

WHERE AND conditions
public andWhere ( array $where, string $type = 'AND' )
$where array Array of conditions for this clause
$type string Keyword that will separate each condition - "AND", "OR"

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

Get current Doctrine DBAL query builder object
public builder ( ) : Doctrine\DBAL\Query\QueryBuilder
Результат Doctrine\DBAL\Query\QueryBuilder

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

Executes separate query with COUNT(*), and drops and ordering (not important for counting)
public count ( ) : integer
Результат integer

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

Delete (passthrough to DBAL QueryBuilder)
public delete ( )

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

Get current entity name query is to be performed on
public entityName ( ) : string
Результат string

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

Escape/quote direct user input
public escape ( string $string ) : string
$string string
Результат string

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

Escape/quote identifier
public escapeIdentifier ( string | array $identifier ) : string | array
$identifier string | array
Результат string | array

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

Execute and return query as a collection
public execute ( ) : mixed
Результат mixed Collection object on success, boolean false on failure

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

Return DBAL Query builder expression
public expr ( ) : Doctrine\DBAL\Query\Expression\ExpressionBuilder
Результат Doctrine\DBAL\Query\Expression\ExpressionBuilder

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

Get field name with table alias appended
public fieldWithAlias ( string $field, boolean $escaped = true ) : string
$field string
$escaped boolean
Результат string

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

Return the first entity matched by the query
public first ( ) : mixed
Результат mixed Spot_Entity on success, boolean false on failure

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

From (passthrough to DBAL QueryBuilder)
public from ( )

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

SPL IteratorAggregate function Called automatically when attribute is used in a 'foreach' loop
public getIterator ( ) : Collection
Результат Spot\Entity\Collection

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

Get all bound query parameters (passthrough to DBAL QueryBuilder)
public getParameters ( ) : mixed
Результат mixed

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

GROUP BY clause
public group ( array $fields = [] )
$fields array Array of field names to use for grouping

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

Having clause to filter results by a calculated value
public having ( array $having, string $type = 'AND' )
$having array Array (like where) for HAVING statement for filter records by
$type string

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

JsonSerializable
public jsonSerialize ( )

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

Limit executed query to specified amount of records Implemented at adapter-level for databases that support it
public limit ( integer $limit, integer $offset = null )
$limit integer Number of records to return
$offset integer Record to start at for limited result set

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

Get current adapter object
public mapper ( ) : Mapper
Результат Mapper

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

Set field and value quoting on/off - maily used for testing output SQL since quoting is different per platform
public noQuote ( boolean $noQuote = true )
$noQuote boolean

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

Offset executed query to skip specified amount of records Implemented at adapter-level for databases that support it
public offset ( integer $offset )
$offset integer Record to start at for limited result set

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

SPL - ArrayAccess
public offsetExists ( $key )

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

SPL - ArrayAccess
public offsetGet ( $key )

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

SPL - ArrayAccess
public offsetSet ( $key, $value )

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

SPL - ArrayAccess
public offsetUnset ( $key )

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

WHERE OR conditions
public orWhere ( array $where, string $type = 'AND' )
$where array Array of conditions for this clause
$type string Keyword that will separate each condition - "AND", "OR"

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

ORDER BY columns
public order ( array $order )
$order array Array of field names to use for sorting

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

Select (passthrough to DBAL QueryBuilder)
public select ( )

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

Set query parameters (passthrough to DBAL QueryBuilder)
public setParameters ( )

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

Convenience function passthrough for Collection
public toArray ( string | null $keyColumn = null, string | null $valueColumn = null ) : array
$keyColumn string | null
$valueColumn string | null
Результат array

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

Get raw SQL string from built query
public toSql ( ) : string
Результат string

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

Removes escape/quote character
public unescapeIdentifier ( string $identifier ) : string
$identifier string
Результат string

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

WHERE conditions
public where ( array $where, string $type = 'AND' )
$where array Array of conditions for this clause
$type string Keyword that will separate each condition - "AND", "OR"

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

WHERE field + raw SQL
public whereFieldSql ( string $field, string $sql, array $params = [] )
$field string Field name for SQL statement (will be quoted)
$sql string SQL string to put in WHERE clause
$params array

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

WHERE conditions
public whereSql ( string $sql )
$sql string SQL string to put in WHERE clause

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

Relations to be eager-loaded
public with ( mixed | null $relations = null )
$relations mixed | null Array/string of relation(s) to be loaded.

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

$_customMethods защищенное статическое свойство

Custom methods added by extensions or plugins
protected static array $_customMethods
Результат array

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

Storage for eager-loaded relations
protected array $_data
Результат array

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

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

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

protected Mapper,Spot $_mapper
Результат Mapper

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

protected bool $_noQuote
Результат boolean

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

protected $_queryBuilder

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

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

$_whereOperatorObjects защищенное статическое свойство

Already instantiated operator objects
protected static array $_whereOperatorObjects
Результат array

$_whereOperators защищенное статическое свойство

protected static array $_whereOperators
Результат array

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

Storage for query properties
protected array $with
Результат array