QueryBuilder

Object oriented approach to building SQL queries.

It's a facade to the Doctrine DBAL QueryBuilder that implements PHP7 type hinting and automatic quoting of table and column names.

$query->select('aField', 'anotherField') ->from('aTable') ->where($query->expr()->eq('aField', 1)) ->andWhere($query->expr()->gte('anotherField',10')) ->execute()

Additional functionality included is support for COUNT() and TRUNCATE() statements.

Table of Contents

Properties

$additionalRestrictions  : array<string|int, mixed>
$concreteQueryBuilder  : QueryBuilder
$connection  : Connection
The DBAL Connection.
$restrictionContainer  : QueryRestrictionContainerInterface

Methods

__clone()  : mixed
Deep clone of the QueryBuilder
__construct()  : mixed
Initializes a new QueryBuilder.
__toString()  : string
Gets a string representation of this QueryBuilder which corresponds to the final SQL query being constructed.
add()  : QueryBuilder
Either appends to or replaces a single, generic query part.
addGroupBy()  : QueryBuilder
Adds a grouping expression to the query.
addOrderBy()  : QueryBuilder
Adds an ordering to the query results.
addSelect()  : QueryBuilder
Adds an item that is to be returned in the query result.
addSelectLiteral()  : QueryBuilder
Adds an item that is to be returned in the query result. This should only be used for literal SQL expressions as no quoting/escaping of any kind will be performed on the items.
andHaving()  : QueryBuilder
Adds a restriction over the groups of the query, forming a logical conjunction with any existing having restrictions.
andWhere()  : QueryBuilder
Adds one or more restrictions to the query results, forming a logical conjunction with any previously specified restrictions.
castFieldToTextType()  : string
Creates a cast of the $fieldName to a text datatype depending on the database management system.
count()  : QueryBuilder
Specifies the item that is to be counted in the query result.
createNamedParameter()  : string
Creates a new named parameter and bind the value $value to it.
createPositionalParameter()  : string
Creates a new positional parameter and bind the given value to it.
delete()  : QueryBuilder
Turns the query being built into a bulk delete query that ranges over a certain table.
distinct()  : QueryBuilder
Specifies that this query should be DISTINCT.
escapeLikeWildcards()  : string
Quotes like wildcards for given string value.
execute()  : Result|int
Executes this query using the bound parameters and their types.
executeQuery()  : Result
Executes an SQL query (SELECT) and returns a Result.
executeStatement()  : int
Executes an SQL statement (INSERT, UPDATE and DELETE) and returns the number of affected rows.
expr()  : ExpressionBuilder
Gets an ExpressionBuilder used for object-oriented construction of query expressions.
from()  : QueryBuilder
Creates and adds a query root corresponding to the table identified by the given alias, forming a cartesian product with any existing query roots.
getConcreteQueryBuilder()  : QueryBuilder
Gets the concrete implementation of the query builder
getConnection()  : Connection
Gets the associated DBAL Connection for this query builder.
getFirstResult()  : int
Gets the position of the first result the query object was set to retrieve (the "offset").
getMaxResults()  : int
Gets the maximum number of results the query object was set to retrieve (the "limit").
getParameter()  : mixed
Gets a (previously set) query parameter of the query being constructed.
getParameters()  : array<string|int, mixed>
Gets all defined query parameters for the query being constructed indexed by parameter index or name.
getParameterType()  : mixed
Gets a (previously set) query parameter type of the query being constructed.
getParameterTypes()  : array<string|int, mixed>
Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
getQueryPart()  : mixed
Gets a query part by its name.
getQueryParts()  : array<string|int, mixed>
Gets all query parts.
getRestrictions()  : QueryRestrictionContainerInterface
getSQL()  : string
Gets the complete SQL string formed by the current specifications of this QueryBuilder.
getState()  : int
Gets the state of this query builder instance.
getType()  : int
Gets the type of the currently built query.
groupBy()  : QueryBuilder
Specifies a grouping over the results of the query.
having()  : QueryBuilder
Specifies a restriction over the groups of the query.
innerJoin()  : QueryBuilder
Creates and adds a join to the query.
insert()  : QueryBuilder
Turns the query being built into an insert query that inserts into a certain table
join()  : QueryBuilder
Creates and adds a join to the query.
leftJoin()  : QueryBuilder
Creates and adds a left join to the query.
limitRestrictionsToTables()  : void
Limits ALL currently active restrictions of the restriction container to the table aliases given
orderBy()  : QueryBuilder
Specifies an ordering for the query results.
orHaving()  : QueryBuilder
Adds a restriction over the groups of the query, forming a logical disjunction with any existing having restrictions.
orWhere()  : QueryBuilder
Adds one or more restrictions to the query results, forming a logical disjunction with any previously specified restrictions.
prepare()  : Statement
Create prepared statement out of QueryBuilder instance.
quote()  : mixed
Quotes a given input parameter.
quoteArrayBasedValueListToIntegerList()  : string
Implode array to comma separated list with database int-quoted values to be used as direct value list for database 'in(...)' or 'notIn(...') expressions. Empty array will return 'NULL' as string to avoid database query failure, as 'IN()' is invalid, but 'IN(NULL)' is fine.
quoteArrayBasedValueListToStringList()  : string
Implode array to comma separated list with database string-quoted values to be used as direct value list for database 'in(...)' or 'notIn(...') expressions. Empty array will return 'NULL' as string to avoid database query failure, as 'IN()' is invalid, but 'IN(NULL)' is fine.
quoteColumnValuePairs()  : array<string|int, mixed>
Quotes an associative array of column-value so the column names can be safely used, even if the name is a reserved name.
quoteIdentifier()  : string
Quotes a string so it can be safely used as a table or column name, even if it is a reserved name.
quoteIdentifiers()  : array<string|int, mixed>
Quotes an array of column names so it can be safely used, even if the name is a reserved name.
quoteIdentifiersForSelect()  : array<string|int, mixed>
Quotes an array of column names so it can be safely used, even if the name is a reserved name.
resetQueryPart()  : QueryBuilder
Resets a single SQL part.
resetQueryParts()  : QueryBuilder
Resets SQL parts.
resetRestrictions()  : void
Re-apply default restrictions
rightJoin()  : QueryBuilder
Creates and adds a right join to the query.
select()  : QueryBuilder
Specifies items that are to be returned in the query result.
selectLiteral()  : QueryBuilder
Specifies items that are to be returned in the query result.
set()  : QueryBuilder
Sets a new value for a column in a bulk update query.
setFirstResult()  : QueryBuilder
Sets the position of the first result to retrieve (the "offset").
setMaxResults()  : QueryBuilder
Sets the maximum number of results to retrieve (the "limit").
setParameter()  : QueryBuilder
Sets a query parameter for the query being constructed.
setParameters()  : QueryBuilder
Sets a collection of query parameters for the query being constructed.
setRestrictions()  : void
setValue()  : QueryBuilder
Sets a value for a column in an insert query.
update()  : QueryBuilder
Turns the query being built into a bulk update query that ranges over a certain table
values()  : QueryBuilder
Specifies values for an insert query indexed by column names.
where()  : QueryBuilder
Specifies one or more restrictions to the query result.
addAdditionalWhereConditions()  : CompositeExpression|mixed
Add the additional query conditions returned by the QueryRestrictionBuilder to the current query and return the original set of conditions so that they can be restored after the query has been built/executed.
getQueriedTables()  : array<string|int, string>
Return all tables/aliases used in FROM or JOIN query parts from the query builder.
unquoteSingleIdentifier()  : string
Unquote a single identifier (no dot expansion). Used to unquote the table names from the expressionBuilder so that the table can be found in the TCA definition.

Properties

$additionalRestrictions

protected array<string|int, mixed> $additionalRestrictions

$concreteQueryBuilder

protected QueryBuilder $concreteQueryBuilder

Methods

__clone()

Deep clone of the QueryBuilder

public __clone() : mixed
Tags
see
QueryBuilder::__clone()

__construct()

Initializes a new QueryBuilder.

public __construct(Connection $connection[, QueryRestrictionContainerInterface|null $restrictionContainer = null ][, QueryBuilder|null $concreteQueryBuilder = null ][, array<string|int, mixed>|null $additionalRestrictions = null ]) : mixed
Parameters
$connection : Connection

The DBAL Connection.

$restrictionContainer : QueryRestrictionContainerInterface|null = null
$concreteQueryBuilder : QueryBuilder|null = null
$additionalRestrictions : array<string|int, mixed>|null = null

__toString()

Gets a string representation of this QueryBuilder which corresponds to the final SQL query being constructed.

public __toString() : string
Return values
string

The string representation of this QueryBuilder.

add()

Either appends to or replaces a single, generic query part.

public add(string $sqlPartName, string|array<string|int, mixed> $sqlPart[, bool $append = false ]) : QueryBuilder

The available parts are: 'select', 'from', 'set', 'where', 'groupBy', 'having' and 'orderBy'.

Parameters
$sqlPartName : string
$sqlPart : string|array<string|int, mixed>
$append : bool = false
Return values
QueryBuilder

This QueryBuilder instance.

addGroupBy()

Adds a grouping expression to the query.

public addGroupBy(string ...$groupBy) : QueryBuilder
Parameters
$groupBy : string

The grouping expression.

Return values
QueryBuilder

This QueryBuilder instance.

addOrderBy()

Adds an ordering to the query results.

public addOrderBy(string $fieldName[, string|null $order = null ]) : QueryBuilder
Parameters
$fieldName : string

The fieldName to order by. Will be quoted according to database platform automatically.

$order : string|null = null

The ordering direction.

Return values
QueryBuilder

This QueryBuilder instance.

addSelect()

Adds an item that is to be returned in the query result.

public addSelect(string ...$selects) : QueryBuilder
Parameters
$selects : string
Return values
QueryBuilder

This QueryBuilder instance.

addSelectLiteral()

Adds an item that is to be returned in the query result. This should only be used for literal SQL expressions as no quoting/escaping of any kind will be performed on the items.

public addSelectLiteral(string ...$selects) : QueryBuilder
Parameters
$selects : string

Literal SQL expressions to be selected.

Return values
QueryBuilder

This QueryBuilder instance.

andHaving()

Adds a restriction over the groups of the query, forming a logical conjunction with any existing having restrictions.

public andHaving(mixed ...$having) : QueryBuilder
Parameters
$having : mixed

The restriction to append.

Return values
QueryBuilder

This QueryBuilder instance.

andWhere()

Adds one or more restrictions to the query results, forming a logical conjunction with any previously specified restrictions.

public andWhere(string|CompositeExpression ...$where) : QueryBuilder
Parameters
$where : string|CompositeExpression

The query restrictions.

Tags
see
where()
Return values
QueryBuilder

This QueryBuilder instance.

castFieldToTextType()

Creates a cast of the $fieldName to a text datatype depending on the database management system.

public castFieldToTextType(string $fieldName) : string
Parameters
$fieldName : string

The fieldname will be quoted and casted according to database platform automatically

Return values
string

count()

Specifies the item that is to be counted in the query result.

public count(string $item) : QueryBuilder

Replaces any previously specified selections, if any.

Parameters
$item : string

Will be quoted according to database platform automatically.

Return values
QueryBuilder

This QueryBuilder instance.

createNamedParameter()

Creates a new named parameter and bind the value $value to it.

public createNamedParameter(mixed $value[, int $type = PDO::PARAM_STR ][, string|null $placeHolder = null ]) : string

This method provides a shortcut for PDOStatement::bindValue when using prepared statements.

The parameter $value specifies the value that you want to bind. If $placeholder is not provided bindValue() will automatically create a placeholder for you. An automatic placeholder will be of the name ':dcValue1', ':dcValue2' etc.

Parameters
$value : mixed
$type : int = PDO::PARAM_STR
$placeHolder : string|null = null

The name to bind with. The string must start with a colon ':'.

Return values
string

the placeholder name used.

createPositionalParameter()

Creates a new positional parameter and bind the given value to it.

public createPositionalParameter(mixed $value[, int $type = PDO::PARAM_STR ]) : string

Attention: If you are using positional parameters with the query builder you have to be very careful to bind all parameters in the order they appear in the SQL statement , otherwise they get bound in the wrong order which can lead to serious bugs in your code.

Parameters
$value : mixed
$type : int = PDO::PARAM_STR
Return values
string

delete()

Turns the query being built into a bulk delete query that ranges over a certain table.

public delete(string $delete[, string|null $alias = null ]) : QueryBuilder
Parameters
$delete : string

The table whose rows are subject to the deletion. Will be quoted according to database platform automatically.

$alias : string|null = null

The table alias used in the constructed query. Will be quoted according to database platform automatically.

Return values
QueryBuilder

This QueryBuilder instance.

escapeLikeWildcards()

Quotes like wildcards for given string value.

public escapeLikeWildcards(string $value) : string
Parameters
$value : string

The value to be quoted.

Return values
string

The quoted value.

execute()

Executes this query using the bound parameters and their types.

public execute() : Result|int

doctrine/dbal decided to split execute() into executeQuery() and executeStatement() for doctrine/dbal:^3.0, like it was done on connection level already, thus these methods are added to this decorator class also as preparation for extension authors, that they are able to write code which is compatible across two core versions and avoid deprecation warning. Additional this will ease backports without the need to switch between execute() and executeQuery().

It is recommended to use directly executeQuery() for 'SELECT' and executeStatement() for 'INSERT', 'UPDATE' and 'DELETE' queries.

Tags
throws
DBALException
todo

Deprecate in v12 along with raise to min doctrine/dbal:^3.2 to align with doctrine/dbal deprecation.

Return values
Result|int

executeQuery()

Executes an SQL query (SELECT) and returns a Result.

public executeQuery() : Result

doctrine/dbal decided to split execute() into executeQuery() and executeStatement() for doctrine/dbal:^3.0, like it was done on connection level already, thus these methods are added to this decorator class also as preparation for extension authors, that they are able to write code which is compatible across two core versions and avoid deprecation warning. Additional this will ease backport without the need to switch if execute() is not used anymore.

Tags
throws
DBALException
Return values
Result

executeStatement()

Executes an SQL statement (INSERT, UPDATE and DELETE) and returns the number of affected rows.

public executeStatement() : int

doctrine/dbal decided to split execute() into executeQuery() and executeStatement() for doctrine/dbal:^3.0, like it was done on connection level already, thus these methods are added to this decorator class also as preparation for extension authors, that they are able to write code which is compatible across two core versions and avoid deprecation warning. Additional this will ease backport without the need to switch if execute() is not used anymore.

Tags
throws
DBALException
Return values
int

The number of affected rows.

expr()

Gets an ExpressionBuilder used for object-oriented construction of query expressions.

public expr() : ExpressionBuilder

This producer method is intended for convenient inline usage. Example:

For more complex expression construction, consider storing the expression builder object in a local variable.

Return values
ExpressionBuilder

from()

Creates and adds a query root corresponding to the table identified by the given alias, forming a cartesian product with any existing query roots.

public from(string $from[, string|null $alias = null ]) : QueryBuilder
Parameters
$from : string

The table. Will be quoted according to database platform automatically.

$alias : string|null = null

The alias of the table. Will be quoted according to database platform automatically.

Return values
QueryBuilder

This QueryBuilder instance.

getConcreteQueryBuilder()

Gets the concrete implementation of the query builder

public getConcreteQueryBuilder() : QueryBuilder
Internal
Return values
QueryBuilder

getFirstResult()

Gets the position of the first result the query object was set to retrieve (the "offset").

public getFirstResult() : int

Returns NULL if was not applied to this QueryBuilder.

Return values
int

The position of the first result.

getMaxResults()

Gets the maximum number of results the query object was set to retrieve (the "limit").

public getMaxResults() : int

Returns 0 if setMaxResults was not applied to this query builder.

Return values
int

The maximum number of results.

getParameter()

Gets a (previously set) query parameter of the query being constructed.

public getParameter(string|int $key) : mixed
Parameters
$key : string|int

The key (index or name) of the bound parameter.

Return values
mixed

The value of the bound parameter.

getParameters()

Gets all defined query parameters for the query being constructed indexed by parameter index or name.

public getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

The currently defined query parameters indexed by parameter index or name.

getParameterType()

Gets a (previously set) query parameter type of the query being constructed.

public getParameterType(string|int $key) : mixed
Parameters
$key : string|int

The key (index or name) of the bound parameter type.

Return values
mixed

The value of the bound parameter type.

getParameterTypes()

Gets all defined query parameter types for the query being constructed indexed by parameter index or name.

public getParameterTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

The currently defined query parameter types indexed by parameter index or name.

getQueryPart()

Gets a query part by its name.

public getQueryPart(string $queryPartName) : mixed
Parameters
$queryPartName : string

getQueryParts()

Gets all query parts.

public getQueryParts() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSQL()

Gets the complete SQL string formed by the current specifications of this QueryBuilder.

public getSQL() : string

If the statement is a SELECT TYPE query restrictions based on TCA settings will automatically be applied based on the current QuerySettings.

Return values
string

The SQL query string.

getState()

Gets the state of this query builder instance.

public getState() : int
Internal
Return values
int

Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.

getType()

Gets the type of the currently built query.

public getType() : int
Internal
Return values
int

groupBy()

Specifies a grouping over the results of the query.

public groupBy(string ...$groupBy) : QueryBuilder

Replaces any previously specified groupings, if any.

Parameters
$groupBy : string

The grouping expression.

Return values
QueryBuilder

This QueryBuilder instance.

having()

Specifies a restriction over the groups of the query.

public having(mixed ...$having) : QueryBuilder

Replaces any previous having restrictions, if any.

Parameters
$having : mixed

The restriction over the groups.

Return values
QueryBuilder

This QueryBuilder instance.

innerJoin()

Creates and adds a join to the query.

public innerJoin(string $fromAlias, string $join, string $alias[, string|null $condition = null ]) : QueryBuilder
Parameters
$fromAlias : string

The alias that points to a from clause.

$join : string

The table name to join.

$alias : string

The alias of the join table.

$condition : string|null = null

The condition for the join.

Return values
QueryBuilder

This QueryBuilder instance.

insert()

Turns the query being built into an insert query that inserts into a certain table

public insert(string $insert) : QueryBuilder
Parameters
$insert : string

The table into which the rows should be inserted.

Return values
QueryBuilder

This QueryBuilder instance.

join()

Creates and adds a join to the query.

public join(string $fromAlias, string $join, string $alias[, string|null $condition = null ]) : QueryBuilder
Parameters
$fromAlias : string

The alias that points to a from clause.

$join : string

The table name to join.

$alias : string

The alias of the join table.

$condition : string|null = null

The condition for the join.

Return values
QueryBuilder

This QueryBuilder instance.

leftJoin()

Creates and adds a left join to the query.

public leftJoin(string $fromAlias, string $join, string $alias[, string|null $condition = null ]) : QueryBuilder
Parameters
$fromAlias : string

The alias that points to a from clause.

$join : string

The table name to join.

$alias : string

The alias of the join table.

$condition : string|null = null

The condition for the join.

Return values
QueryBuilder

This QueryBuilder instance.

limitRestrictionsToTables()

Limits ALL currently active restrictions of the restriction container to the table aliases given

public limitRestrictionsToTables(array<string|int, mixed> $tableAliases) : void
Parameters
$tableAliases : array<string|int, mixed>

orderBy()

Specifies an ordering for the query results.

public orderBy(string $fieldName[, string|null $order = null ]) : QueryBuilder

Replaces any previously specified orderings, if any.

Parameters
$fieldName : string

The fieldName to order by. Will be quoted according to database platform automatically.

$order : string|null = null

The ordering direction. No automatic quoting/escaping.

Return values
QueryBuilder

This QueryBuilder instance.

orHaving()

Adds a restriction over the groups of the query, forming a logical disjunction with any existing having restrictions.

public orHaving(mixed ...$having) : QueryBuilder
Parameters
$having : mixed

The restriction to add.

Return values
QueryBuilder

This QueryBuilder instance.

orWhere()

Adds one or more restrictions to the query results, forming a logical disjunction with any previously specified restrictions.

public orWhere(string|CompositeExpression ...$where) : QueryBuilder
Parameters
$where : string|CompositeExpression

The WHERE statement.

Tags
see
where()
Return values
QueryBuilder

This QueryBuilder instance.

prepare()

Create prepared statement out of QueryBuilder instance.

public prepare() : Statement

doctrine/dbal does not provide support for prepared statement in QueryBuilder, but as TYPO3 uses the API throughout the code via QueryBuilder, so the functionality of prepared statements for multiple executions is added.

You should be aware that this method will throw a named 'UnsupportedPreparedStatementParameterTypeException()' exception, if 'PARAM_INT_ARRAY' or 'PARAM_STR_ARRAY' is set, as this is not supported for prepared statements directly.

NamedPlaceholder are not supported, and if one or more are set a 'NamedParameterNotSupportedForPreparedStatementException' will be thrown.

Return values
Statement

quote()

Quotes a given input parameter.

public quote(mixed $input[, int|null $type = PDO::PARAM_STR ]) : mixed
Parameters
$input : mixed

The parameter to be quoted.

$type : int|null = PDO::PARAM_STR

The type of the parameter.

Tags
todo:

Change signature to quote($input, int $type = \PDO::PARAM_STR) - not nullable anymore, as breaking change in v12.

Return values
mixed

Often string, but also int or float or similar depending on $input and platform

quoteArrayBasedValueListToIntegerList()

Implode array to comma separated list with database int-quoted values to be used as direct value list for database 'in(...)' or 'notIn(...') expressions. Empty array will return 'NULL' as string to avoid database query failure, as 'IN()' is invalid, but 'IN(NULL)' is fine.

public quoteArrayBasedValueListToIntegerList(array<string|int, mixed> $values) : string

This method should be used with care, the preferred way is to use placeholders. It is however useful when dealing with potentially many values, which could reach placeholder limit quickly.

When working with prepared statement from QueryBuilder, use this method to proper quote array with integer values.

The method can not be used in queries that re-bind a prepared statement to change values for subsequent execution due to a PDO limitation.

Return value should only be used as value list for database queries 'in()' and 'notIn()' .

Parameters
$values : array<string|int, mixed>
Return values
string

quoteArrayBasedValueListToStringList()

Implode array to comma separated list with database string-quoted values to be used as direct value list for database 'in(...)' or 'notIn(...') expressions. Empty array will return 'NULL' as string to avoid database query failure, as 'IN()' is invalid, but 'IN(NULL)' is fine.

public quoteArrayBasedValueListToStringList(array<string|int, mixed> $values) : string

This method should be used with care, the preferred way is to use placeholders. It is however useful when dealing with potentially many values, which could reach placeholder limit quickly.

When working with prepared statement from QueryBuilder, use this method to proper quote array with integer values.

The method can not be used in queries that re-bind a prepared statement to change values for subsequent execution due to a PDO limitation.

Return value should only be used as value list for database queries 'in()' and 'notIn()' .

Parameters
$values : array<string|int, mixed>
Return values
string

quoteColumnValuePairs()

Quotes an associative array of column-value so the column names can be safely used, even if the name is a reserved name.

public quoteColumnValuePairs(array<string|int, mixed> $input) : array<string|int, mixed>

Delimiting style depends on the underlying database platform that is being used.

Parameters
$input : array<string|int, mixed>
Return values
array<string|int, mixed>

quoteIdentifier()

Quotes a string so it can be safely used as a table or column name, even if it is a reserved name.

public quoteIdentifier(string $identifier) : string

Delimiting style depends on the underlying database platform that is being used.

Parameters
$identifier : string

The name to be quoted.

Return values
string

The quoted name.

quoteIdentifiers()

Quotes an array of column names so it can be safely used, even if the name is a reserved name.

public quoteIdentifiers(array<string|int, mixed> $input) : array<string|int, mixed>

Delimiting style depends on the underlying database platform that is being used.

Parameters
$input : array<string|int, mixed>
Return values
array<string|int, mixed>

quoteIdentifiersForSelect()

Quotes an array of column names so it can be safely used, even if the name is a reserved name.

public quoteIdentifiersForSelect(array<string|int, mixed> $input) : array<string|int, mixed>

Takes into account the special case of the * placeholder that can only be used in SELECT type statements.

Delimiting style depends on the underlying database platform that is being used.

Parameters
$input : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

resetQueryPart()

Resets a single SQL part.

public resetQueryPart(string $queryPartName) : QueryBuilder
Parameters
$queryPartName : string
Return values
QueryBuilder

This QueryBuilder instance.

resetQueryParts()

Resets SQL parts.

public resetQueryParts([array<string|int, mixed>|null $queryPartNames = null ]) : QueryBuilder
Parameters
$queryPartNames : array<string|int, mixed>|null = null
Return values
QueryBuilder

This QueryBuilder instance.

resetRestrictions()

Re-apply default restrictions

public resetRestrictions() : void

rightJoin()

Creates and adds a right join to the query.

public rightJoin(string $fromAlias, string $join, string $alias[, string|null $condition = null ]) : QueryBuilder
Parameters
$fromAlias : string

The alias that points to a from clause.

$join : string

The table name to join.

$alias : string

The alias of the join table.

$condition : string|null = null

The condition for the join.

Return values
QueryBuilder

This QueryBuilder instance.

select()

Specifies items that are to be returned in the query result.

public select(string ...$selects) : QueryBuilder

Replaces any previously specified selections, if any.

Parameters
$selects : string
Return values
QueryBuilder

This QueryBuilder instance.

selectLiteral()

Specifies items that are to be returned in the query result.

public selectLiteral(string ...$selects) : QueryBuilder

Replaces any previously specified selections, if any. This should only be used for literal SQL expressions as no quoting/escaping of any kind will be performed on the items.

Parameters
$selects : string

Literal SQL expressions to be selected. Warning: No quoting will be done!

Return values
QueryBuilder

This QueryBuilder instance.

set()

Sets a new value for a column in a bulk update query.

public set(string $key, mixed $value[, bool $createNamedParameter = true ][, int $type = PDO::PARAM_STR ]) : QueryBuilder
Parameters
$key : string

The column to set.

$value : mixed

The value, expression, placeholder, etc.

$createNamedParameter : bool = true

Automatically create a named parameter for the value

$type : int = PDO::PARAM_STR
Return values
QueryBuilder

This QueryBuilder instance.

setFirstResult()

Sets the position of the first result to retrieve (the "offset").

public setFirstResult(int $firstResult) : QueryBuilder
Parameters
$firstResult : int

The first result to return.

Return values
QueryBuilder

This QueryBuilder instance.

setMaxResults()

Sets the maximum number of results to retrieve (the "limit").

public setMaxResults(int $maxResults) : QueryBuilder
Parameters
$maxResults : int

The maximum number of results to retrieve.

Return values
QueryBuilder

This QueryBuilder instance.

setParameter()

Sets a query parameter for the query being constructed.

public setParameter(string|int $key, mixed $value[, int|null $type = null ]) : QueryBuilder
Parameters
$key : string|int

The parameter position or name.

$value : mixed

The parameter value.

$type : int|null = null

One of the Connection::PARAM_* constants.

Return values
QueryBuilder

This QueryBuilder instance.

setParameters()

Sets a collection of query parameters for the query being constructed.

public setParameters(array<string|int, mixed> $params[, array<string|int, mixed> $types = [] ]) : QueryBuilder
Parameters
$params : array<string|int, mixed>

The query parameters to set.

$types : array<string|int, mixed> = []

The query parameters types to set.

Return values
QueryBuilder

This QueryBuilder instance.

setValue()

Sets a value for a column in an insert query.

public setValue(string $column, mixed $value[, bool $createNamedParameter = true ]) : QueryBuilder
Parameters
$column : string

The column into which the value should be inserted.

$value : mixed

The value that should be inserted into the column.

$createNamedParameter : bool = true

Automatically create a named parameter for the value

Return values
QueryBuilder

This QueryBuilder instance.

update()

Turns the query being built into a bulk update query that ranges over a certain table

public update(string $update[, string|null $alias = null ]) : QueryBuilder
Parameters
$update : string

The table whose rows are subject to the update.

$alias : string|null = null

The table alias used in the constructed query.

Return values
QueryBuilder

This QueryBuilder instance.

values()

Specifies values for an insert query indexed by column names.

public values(array<string|int, mixed> $values[, bool $createNamedParameters = true ]) : QueryBuilder

Replaces any previous values, if any.

Parameters
$values : array<string|int, mixed>

The values to specify for the insert query indexed by column names.

$createNamedParameters : bool = true

Automatically create named parameters for all values

Return values
QueryBuilder

This QueryBuilder instance.

where()

Specifies one or more restrictions to the query result.

public where(string|CompositeExpression ...$predicates) : QueryBuilder

Replaces any previously specified restrictions, if any.

Parameters
$predicates : string|CompositeExpression
Return values
QueryBuilder

This QueryBuilder instance.

addAdditionalWhereConditions()

Add the additional query conditions returned by the QueryRestrictionBuilder to the current query and return the original set of conditions so that they can be restored after the query has been built/executed.

protected addAdditionalWhereConditions() : CompositeExpression|mixed
Return values
CompositeExpression|mixed

getQueriedTables()

Return all tables/aliases used in FROM or JOIN query parts from the query builder.

protected getQueriedTables() : array<string|int, string>

The table names are automatically unquoted. This is a helper for to build the list of queried tables for the AbstractRestrictionContainer.

Return values
array<string|int, string>

unquoteSingleIdentifier()

Unquote a single identifier (no dot expansion). Used to unquote the table names from the expressionBuilder so that the table can be found in the TCA definition.

protected unquoteSingleIdentifier(string $identifier) : string
Parameters
$identifier : string

The identifier / table name

Return values
string

The unquoted table name / identifier


        
On this page

Search results