com\setasign\SetaFramework\Database\Query
Select Class Query Select
File: /SetaFramework/src/Database/Query/Select.php
Class hierarchy
Implements
Summary
Methods
- __construct()
- addFilter()
- addOn()
- distinct()
- forShare()
- forShareNoWait()
- forUpdate()
- forUpdateNoWait()
- from()
- getPart()
- getSql()
- getSqlColumns()
- getSqlFrom()
- getSqlGroupBy()
- getSqlHaving()
- getSqlJoin()
- getSqlLimit()
- getSqlLock()
- getSqlOrderBy()
- getSqlWhere()
- getSqlWith()
- groupBy()
- hasPart()
- having()
- havingOr()
- havingOrParentheseOpen()
- havingParentheseClose()
- havingParentheseOpen()
- join()
- joinInner()
- joinLeft()
- joinRight()
- joinStraight()
- limit()
- on()
- onOr()
- onOrParentheseOpen()
- onParentheseClose()
- onParentheseOpen()
- orderBy()
- processFilter()
- reset()
- select()
- where()
- whereOr()
- whereOrParentheseOpen()
- whereParentheseClose()
- whereParentheseOpen()
- whereXor()
- whereXorParentheseOpen()
- with()
- withRecursive()
Properties
Methods
__construct()
Constructor
Parameters
- $columns : string|array|\com\setasign\SetaFramework\Database\ExpressionInterface
addFilter()
string $logic,
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
Add a filter to a specific part
$statementOrColumn can be a Closure if $operator isn't set. The Closure will be called with (AbstractQuery $query, Database $quoteInterface) and has no return. $query won't be inserted directly, only the added parts of type $part will be used and set in parentheses.
Parameters
- $part : array
- $logic : string
Logic operator like "OR" or "AND" or "XOR", not important if this is the first element of a part
- $statementOrColumn : string|\Closure
- $operator : ?string
- $compareValue : mixed
By default, this will be quoted as a value.
addOn()
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
Adds a on-block to last added join
Parameters
- $logic : string
Logic operator like "OR" or "AND", not important if this is the first element of a part
- $statementOrColumn : string|\Closure
- $operator : ?string
- $compareValue : mixed
Exceptions
Throws \BadMethodCallException
from()
Add selected table(s)
The method has no defined count of max arguments. Every param means one table to select from:
If a param is not an array it's simply the tablename without an alias
If a param is an array, the first entry will be the table and second the alias. The first entry can be a string, a Select-Object or a Closure (params: Database\Select $select, QuoteInterface $quoteInterface). The second entry need to be a string. Remember: When you use a Select-Object or Closure your Database need to support subqueries.
Normally the tables will be merged to all existing from-tables except the last param is an boolean TRUE.
Parameters
- $tables : string|array|true
getSql()
Returns the query as string
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlColumns()
Parses content of select-part
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlFrom()
Parses the from-block to string
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlGroupBy()
Parses content of group-by part
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlHaving()
Parses content of having-part
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlJoin()
Parses the join block to string
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlLimit()
Parses the limit block to string
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlOrderBy()
Parses the orderBy block to string
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlWhere()
Parses the where block to string
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
getSqlWith()
Parameters
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
havingOrParentheseOpen()
Starts an HAVING-OR-condition-block in parentheses
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
havingParentheseOpen()
Starts an HAVING-AND-condition-block in parentheses
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
join()
string $joinType = '',
IndexHintList|IndexHintList[] $indexHintList = array ( )
Adds a join to query
Parameters
joinInner()
joinLeft()
joinRight()
joinStraight()
on()
?string $operator = null,
mixed $compareValue = null
Adds a ON-AND-condition to last added join
Parameters
- $statementOrColumn : string|array|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface
By default, this will be quoted as an identifier.
- $operator : ?string
- $compareValue : mixed
By default, this will be quoted as an identifier.
Exceptions
Throws \BadMethodCallException
onOr()
?string $operator = null,
?string $compareValue = null
Adds a ON-OR-condition to last added join
Parameters
- $statementOrColumn : string|array|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface
By default, this will be quoted as an identifier.
- $operator : ?string
- $compareValue : ?string
By default, this will be quoted as an identifier.
onOrParentheseOpen()
Starts a ON-OR-condition-block in parentheses to last added join
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
onParentheseOpen()
Starts a ON-AND-condition-block in parentheses to last added join
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
orderBy()
string $direction = 'ASC'
Adds an order-by-column to query
Parameters
- $column : string|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface
By default, quoted as an identifier.
- $direction : string
'ASC' or 'DESC'
processFilter()
Parses a single part to string
Parameters
- $parts : array
- $quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
- $mainPart : string
Exceptions
Throws \InvalidArgumentException
select()
bool $overwrite = false
Add selected column(s)
If this method will be called more than once the selected columns will be merged if $overwrite is false
Parameters
- $columns : string|array|\com\setasign\SetaFramework\Database\ExpressionInterface
- $overwrite : bool
where()
?string $operator = null,
mixed $compareValue = null
Adds a WHERE-AND-condition to where part
Parameters
- $statementOrColumn : string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface
By default, quoted as an identifier.
- $operator : ?string
- $compareValue : mixed
By default, this will be quoted as a value.
whereOr()
?string $operator = null,
mixed $compareValue = null
Adds a WHERE-OR-condition to where part
Parameters
- $statementOrColumn : string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface
By default, quoted as an identifier.
- $operator : ?string
- $compareValue : mixed
By default, this will be quoted as a value.
whereOrParentheseOpen()
Starts an WHERE-OR-condition-block in parentheses
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
whereParentheseOpen()
Starts an WHERE-AND-condition-block in parentheses
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
whereXor()
?string $operator = null,
mixed $compareValue = null
Adds a WHERE-XOR-condition to where part
Parameters
- $statementOrColumn : string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface
By default, quoted as an identifier.
- $operator : ?string
- $compareValue : mixed
By default, this will be quoted as a value.
whereXorParentheseOpen()
Starts an WHERE-XOR-condition-block in parentheses
There is no autoclosing of parentheses.
Parameters
- $reverse : bool
Reverse result of parenthese with prefix NOT
