com\setasign\Konquadrat\Object\Database

ObjectSelect Class Query Select

File: /Konquadrat/src/Object/Database/ObjectSelect.php

Class hierarchy

  • com\setasign\SetaFramework\Database\Query\Select

Implements

  • \com\setasign\SetaFramework\Database\SqlInterface

Summary

Properties

$ignoreShowDeletedFlag

$includeAllFields

$includeTypeFilter

$joinedTables

private ObjectSelect::$joinedTables = array(...)

$languageManager

$mainTable

$objectConfig

$objectFinder

$parts

protected array \com\setasign\SetaFramework\Database\Query\AbstractQuery::$parts = array()

Contains the single parts of the statement

$selectFields

private ObjectSelect::$selectFields = array(...)

$type

$unjoinedTables


Methods

__construct()

public ObjectSelect::__construct (
string|array|\com\setasign\SetaFramework\Database\ExpressionInterface $objectConfig,
\com\setasign\Konquadrat\Object\ObjectFinder $objectFinder,
\com\setasign\Konquadrat\LanguageManager $languageManager,
string $type,
bool $ignoreShowDeletedFlag = false,
?string $priorityTable = null
)

Constructor

Parameters
$objectConfig : string|array|\com\setasign\SetaFramework\Database\ExpressionInterface
 
$objectFinder : \com\setasign\Konquadrat\Object\ObjectFinder
 
$languageManager : \com\setasign\Konquadrat\LanguageManager
 
$type : string
 
$ignoreShowDeletedFlag : bool
 
$priorityTable : ?string
 

addFilter()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::addFilter (
array &$part,
string $logic,
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

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()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::addOn (
string $logic,
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

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

distinct()

public \com\setasign\SetaFramework\Database\Query\Select::distinct (
bool $distinct = true
): static
Parameters
$distinct : bool
 

ensureTableJoin()

private ObjectSelect::ensureTableJoin (
string $tableName
): void
Parameters
$tableName : string
 

forShare()

public \com\setasign\SetaFramework\Database\Query\Select::forShare (
void
): static

forShareNoWait()

public \com\setasign\SetaFramework\Database\Query\Select::forShareNoWait (
void
): static

forUpdate()

public \com\setasign\SetaFramework\Database\Query\Select::forUpdate (
void
): static

forUpdateNoWait()

public \com\setasign\SetaFramework\Database\Query\Select::forUpdateNoWait (
void
): static

from()

public \com\setasign\SetaFramework\Database\Query\Select::from (
string|array|true ...$tables
): static

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
 

getPart()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::getPart (
string $part
): ?mixed

Returns the defined part

Parameters
$part : string
 

getSql()

public ObjectSelect::getSql (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Returns the query as string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlColumns()

protected \com\setasign\SetaFramework\Database\Query\Select::getSqlColumns (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses content of select-part

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlFrom()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::getSqlFrom (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses the from-block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlGroupBy()

protected \com\setasign\SetaFramework\Database\Query\Select::getSqlGroupBy (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses content of group-by part

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlHaving()

protected \com\setasign\SetaFramework\Database\Query\Select::getSqlHaving (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses content of having-part

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlJoin()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::getSqlJoin (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses the join block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlLimit()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::getSqlLimit (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses the limit block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlLock()

protected \com\setasign\SetaFramework\Database\Query\Select::getSqlLock (
void
): string

getSqlOrderBy()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::getSqlOrderBy (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses the orderBy block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlWhere()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::getSqlWhere (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string

Parses the where block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlWith()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::getSqlWith (
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface
): string
Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

groupBy()

public \com\setasign\SetaFramework\Database\Query\Select::groupBy (
string|array $columns
): static

Adds group-by column(s)

The column(s) will be merged to all existing group-by columns

Parameters
$columns : string|array
 

hasPart()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::hasPart (
string $part
): bool
Parameters
$part : string
 

having()

public \com\setasign\SetaFramework\Database\Query\Select::having (
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a HAVING-AND-condition to query

Parameters
$statementOrColumn : string|\Closure
 
$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as a value.

havingOr()

public \com\setasign\SetaFramework\Database\Query\Select::havingOr (
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a HAVING-OR-condition to query

Parameters
$statementOrColumn : string|\Closure
 
$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as a value.

havingOrParentheseOpen()

public \com\setasign\SetaFramework\Database\Query\Select::havingOrParentheseOpen (
bool $reverse = false
): static

Starts an HAVING-OR-condition-block in parentheses

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

havingParentheseClose()

public \com\setasign\SetaFramework\Database\Query\Select::havingParentheseClose (
void
): static

Ends the last condition-block in parentheses

havingParentheseOpen()

public \com\setasign\SetaFramework\Database\Query\Select::havingParentheseOpen (
bool $reverse = false
): static

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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::join (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure $table,
string $joinType = '',
\com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[] $indexHintList = array ( )
): static

Adds a join to query

Parameters
$table : string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure

By default, this will be quoted as an identifier.

$joinType : string
 
$indexHintList : \com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[]
 

joinInner()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::joinInner (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure $table,
\com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[] $indexHintList = array ( )
): static

Adds an inner-join to query

Parameters
$table : string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : \com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[]
 

joinLeft()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::joinLeft (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure $table,
\com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[] $indexHintList = array ( )
): static

Adds a left-outer-join to query

Parameters
$table : string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : \com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[]
 

joinRight()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::joinRight (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure $table,
\com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[] $indexHintList = array ( )
): static

Adds a right-outer-join to query

Parameters
$table : string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : \com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[]
 

joinStraight()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::joinStraight (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure $table,
\com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[] $indexHintList = array ( )
): static

Adds a straight-join to query

Parameters
$table : string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : \com\setasign\SetaFramework\Database\Query\IndexHintList|\com\setasign\SetaFramework\Database\Query\IndexHintList[]
 

limit()

public \com\setasign\SetaFramework\Database\Query\Select::limit (
int $limit,
?int $offset = null
): static

Sets a limit for query

Parameters
$limit : int
 
$offset : ?int
 

on()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::on (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a ON-AND-condition to last added join

Parameters
$statementOrColumn : string|array|\com\setasign\SetaFramework\Database\Query\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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::onOr (
string|array|\com\setasign\SetaFramework\Database\Query\Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
?string $compareValue = null
): static

Adds a ON-OR-condition to last added join

Parameters
$statementOrColumn : string|array|\com\setasign\SetaFramework\Database\Query\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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::onOrParentheseOpen (
bool $reverse = false
): static

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

onParentheseClose()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::onParentheseClose (
void
): static

Ends the last on-condition-block in parentheses

onParentheseOpen()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::onParentheseOpen (
bool $reverse = false
): static

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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::orderBy (
string|\com\setasign\SetaFramework\Database\Query\Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $column,
string $direction = 'ASC'
): static

Adds an order-by-column to query

Parameters
$column : string|\com\setasign\SetaFramework\Database\Query\Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, quoted as an identifier.

$direction : string

'ASC' or 'DESC'

processFilter()

protected \com\setasign\SetaFramework\Database\Query\AbstractQuery::processFilter (
array $parts,
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface,
string $mainPart
): string

Parses a single part to string

Parameters
$parts : array
 
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 
$mainPart : string
 
Exceptions

Throws \InvalidArgumentException

reset()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::reset (
?string $part = null
): static

Resets a single part or all parts of the statement

Parameters
$part : ?string
 

resolveColumn()

public ObjectSelect::resolveColumn (
string $fieldName
): \com\setasign\SetaFramework\Database\Expression|string|\Closure

Resolves a field name to the associated database query to fetch the value of the field. This method can resolve reference fields and magic fields.

Parameters
$fieldName : string
 

select()

public \com\setasign\SetaFramework\Database\Query\Select::select (
string|array|\com\setasign\SetaFramework\Database\ExpressionInterface $columns,
bool $overwrite = false
): static

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
 

selectField()

public ObjectSelect::selectField (
string $fieldName,
?string $alias = null
): static
Parameters
$fieldName : string
 
$alias : ?string
 

where()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::where (
string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::whereOr (
string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::whereOrParentheseOpen (
bool $reverse = false
): static

Starts an WHERE-OR-condition-block in parentheses

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

whereParentheseClose()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::whereParentheseClose (
void
): static

Ends the last condition-block in parentheses

whereParentheseOpen()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::whereParentheseOpen (
bool $reverse = false
): static

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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::whereXor (
string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

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()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::whereXorParentheseOpen (
bool $reverse = false
): static

Starts an WHERE-XOR-condition-block in parentheses

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

with()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::with (
string $name,
\com\setasign\SetaFramework\Database\Query\Select|\com\setasign\SetaFramework\Database\Query\Union|\Closure|string $query
): static
Parameters
$name : string
 
$query : \com\setasign\SetaFramework\Database\Query\Select|\com\setasign\SetaFramework\Database\Query\Union|\Closure|string
 

withRecursive()

public \com\setasign\SetaFramework\Database\Query\AbstractQuery::withRecursive (
string $name,
\com\setasign\SetaFramework\Database\Query\Select|\com\setasign\SetaFramework\Database\Query\Union|\Closure|string $query
): static
Parameters
$name : string
 
$query : \com\setasign\SetaFramework\Database\Query\Select|\com\setasign\SetaFramework\Database\Query\Union|\Closure|string