Nextcloud PHP API (master)

ITypedQueryBuilder extends IQueryBuilder

This class provides a wrapper around Doctrine's QueryBuilder

Tags
template-covariant

of never

since
34.0.0
Attributes
#[Consumable]
$since: '34.0.0'

Table of Contents

Constants

MAX_ROW_DELETION  = 100000
PARAM_BOOL  = \Doctrine\DBAL\Types\Types::BOOLEAN
PARAM_DATE  = \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE
PARAM_DATE_IMMUTABLE  = \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE
For passing a \DateTime instance when only interested in the date part (without timezone support)
PARAM_DATE_MUTABLE  = \Doctrine\DBAL\Types\Types::DATE_MUTABLE
For passing a \DateTime instance when only interested in the date part (without timezone support)
PARAM_DATETIME_IMMUTABLE  = \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE
For passing a \DateTime instance (without timezone support)
PARAM_DATETIME_MUTABLE  = \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE
For passing a \DateTime instance (without timezone support)
PARAM_DATETIME_TZ_IMMUTABLE  = \Doctrine\DBAL\Types\Types::DATETIMETZ_IMMUTABLE
For passing a \DateTime instance with timezone support
PARAM_DATETIME_TZ_MUTABLE  = \Doctrine\DBAL\Types\Types::DATETIMETZ_MUTABLE
For passing a \DateTime instance with timezone support
PARAM_INT  = \Doctrine\DBAL\ParameterType::INTEGER
PARAM_INT_ARRAY  = \Doctrine\DBAL\ArrayParameterType::INTEGER
PARAM_JSON  = 'json'
PARAM_LOB  = \Doctrine\DBAL\ParameterType::LARGE_OBJECT
PARAM_NULL  = \Doctrine\DBAL\ParameterType::NULL
PARAM_STR  = \Doctrine\DBAL\ParameterType::STRING
PARAM_STR_ARRAY  = \Doctrine\DBAL\ArrayParameterType::STRING
PARAM_TIME_IMMUTABLE  = \Doctrine\DBAL\Types\Types::TIME_MUTABLE
For passing a \DateTimeImmutable instance when only interested in the time part (without timezone support)
PARAM_TIME_MUTABLE  = \Doctrine\DBAL\Types\Types::TIME_MUTABLE
For passing a \DateTime instance when only interested in the time part (without timezone support)

Methods

addGroupBy()  : $this
Adds a grouping expression to the query.
addOrderBy()  : $this
Adds an ordering to the query results.
addSelect()  : $this
Adds an item that is to be returned in the query result.
andHaving()  : $this
Adds a restriction over the groups of the query, forming a logical conjunction with any existing having restrictions.
andWhere()  : $this
Adds one or more restrictions to the query results, forming a logical conjunction with any previously specified restrictions.
automaticTablePrefix()  : mixed
Enable/disable automatic prefixing of table names with the oc_ prefix
createFunction()  : IQueryFunction
Creates a new function.
createNamedParameter()  : IParameter
Creates a new named parameter and bind the value $value to it.
createParameter()  : IParameter
Creates a new parameter
createPositionalParameter()  : IParameter
Creates a new positional parameter and bind the given value to it.
delete()  : $this
Turns the query being built into a bulk delete query that ranges over a certain table.
executeQuery()  : IResult<string|int, S>
Execute for select statements
executeStatement()  : int
Execute insert, update and delete statements
expr()  : IExpressionBuilder
Gets an ExpressionBuilder used for object-oriented construction of query expressions.
forUpdate()  : $this
Locks the queried rows for a subsequent update.
from()  : $this
Creates and adds a query root corresponding to the table identified by the given alias, forming a cartesian product with any existing query roots.
func()  : IFunctionBuilder
Gets an FunctionBuilder used for object-oriented construction of query functions.
getColumnName()  : string
Returns the column name quoted and with table alias prefix as needed by the implementation
getConnection()  : IDBConnection
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").
getLastInsertId()  : int
Used to get the id of the last inserted element
getMaxResults()  : int|null
Gets the maximum number of results the query object was set to retrieve (the "limit").
getOutputColumns()  : array<string|int, mixed>
Get a list of column names that are expected in the query output
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.
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.
getTableName()  : string
Returns the table name quoted and with database prefix as needed by the implementation.
getType()  : int
Gets the type of the currently built query.
groupBy()  : $this
Specifies a grouping over the results of the query.
having()  : $this
Specifies a restriction over the groups of the query.
hintShardKey()  : $this
Provide a hint for the shard key for queries where this can't be detected otherwise
innerJoin()  : $this
Creates and adds a join to the query.
insert()  : $this
Turns the query being built into an insert query that inserts into a certain table
join()  : $this
Creates and adds a join to the query.
leftJoin()  : $this
Creates and adds a left join to the query.
orderBy()  : $this
Specifies an ordering for the query results.
orHaving()  : $this
Adds a restriction over the groups of the query, forming a logical disjunction with any existing having restrictions.
orWhere()  : $this
Adds one or more restrictions to the query results, forming a logical disjunction with any previously specified restrictions.
prefixTableName()  : string
Returns the table name with database prefix as needed by the implementation
resetQueryPart()  : $this
Resets a single SQL part.
resetQueryParts()  : $this
Resets SQL parts.
rightJoin()  : $this
Creates and adds a right join to the query.
runAcrossAllShards()  : $this
Set the query to run across all shards if sharding is enabled.
select()  : $this
Specifies an item that is to be returned in the query result.
selectAlias()  : $this
Specifies an item that is to be returned with a different name in the query result.
selectColumns()  : $this
selectColumnsDistinct()  : $this
selectDistinct()  : $this
Specifies an item that is to be returned uniquely in the query result.
set()  : $this
Sets a new value for a column in a bulk update query.
setFirstResult()  : $this
Sets the position of the first result to retrieve (the "offset").
setMaxResults()  : $this
Sets the maximum number of results to retrieve (the "limit").
setParameter()  : $this
Sets a query parameter for the query being constructed.
setParameters()  : $this
Sets a collection of query parameters for the query being constructed.
setValue()  : $this
Sets a value for a column in an insert query.
update()  : $this
Turns the query being built into a bulk update query that ranges over a certain table
values()  : $this
Specifies values for an insert query indexed by column names.
where()  : $this
Specifies one or more restrictions to the query result.

Constants

MAX_ROW_DELETION

public mixed MAX_ROW_DELETION = 100000
Tags
since
24.0.0

Indicates how many rows can be deleted at once with MySQL database server.

PARAM_BOOL

public mixed PARAM_BOOL = \Doctrine\DBAL\Types\Types::BOOLEAN
Tags
since
9.0.0

PARAM_DATE

  • use PARAM_DATETIME_MUTABLE instead
public mixed PARAM_DATE = \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE
Tags
since
9.0.0

PARAM_DATE_IMMUTABLE

For passing a \DateTime instance when only interested in the date part (without timezone support)

public mixed PARAM_DATE_IMMUTABLE = \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE
Tags
since
9.0.0

PARAM_DATE_MUTABLE

For passing a \DateTime instance when only interested in the date part (without timezone support)

public mixed PARAM_DATE_MUTABLE = \Doctrine\DBAL\Types\Types::DATE_MUTABLE
Tags
since
31.0.0

PARAM_DATETIME_IMMUTABLE

For passing a \DateTime instance (without timezone support)

public mixed PARAM_DATETIME_IMMUTABLE = \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE
Tags
since
31.0.0

PARAM_DATETIME_MUTABLE

For passing a \DateTime instance (without timezone support)

public mixed PARAM_DATETIME_MUTABLE = \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE
Tags
since
31.0.0

PARAM_DATETIME_TZ_IMMUTABLE

For passing a \DateTime instance with timezone support

public mixed PARAM_DATETIME_TZ_IMMUTABLE = \Doctrine\DBAL\Types\Types::DATETIMETZ_IMMUTABLE
Tags
since
31.0.0

PARAM_DATETIME_TZ_MUTABLE

For passing a \DateTime instance with timezone support

public mixed PARAM_DATETIME_TZ_MUTABLE = \Doctrine\DBAL\Types\Types::DATETIMETZ_MUTABLE
Tags
since
31.0.0

PARAM_INT

public mixed PARAM_INT = \Doctrine\DBAL\ParameterType::INTEGER
Tags
since
9.0.0

PARAM_INT_ARRAY

public mixed PARAM_INT_ARRAY = \Doctrine\DBAL\ArrayParameterType::INTEGER
Tags
since
9.0.0

PARAM_JSON

JSON fields can not properly be used in WHERE statements of Oracle and MySQL. It is recommended to use a simple STRING field and handle JSON within PHP

public mixed PARAM_JSON = 'json'
Tags
since
24.0.0

PARAM_LOB

public mixed PARAM_LOB = \Doctrine\DBAL\ParameterType::LARGE_OBJECT
Tags
since
9.0.0

PARAM_NULL

public mixed PARAM_NULL = \Doctrine\DBAL\ParameterType::NULL
Tags
since
9.0.0

PARAM_STR

public mixed PARAM_STR = \Doctrine\DBAL\ParameterType::STRING
Tags
since
9.0.0

PARAM_STR_ARRAY

public mixed PARAM_STR_ARRAY = \Doctrine\DBAL\ArrayParameterType::STRING
Tags
since
9.0.0

PARAM_TIME_IMMUTABLE

For passing a \DateTimeImmutable instance when only interested in the time part (without timezone support)

public mixed PARAM_TIME_IMMUTABLE = \Doctrine\DBAL\Types\Types::TIME_MUTABLE
Tags
since
31.0.0

PARAM_TIME_MUTABLE

For passing a \DateTime instance when only interested in the time part (without timezone support)

public mixed PARAM_TIME_MUTABLE = \Doctrine\DBAL\Types\Types::TIME_MUTABLE
Tags
since
31.0.0

Methods

addGroupBy()

Adds a grouping expression to the query.

public addGroupBy(mixed ...$groupBy) : $this
Parameters
$groupBy : mixed

The grouping expression.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

addOrderBy()

Adds an ordering to the query results.

public addOrderBy(mixed $sort[, mixed $order = null ]) : $this
Parameters
$sort : mixed

The ordering expression.

$order : mixed = null

The ordering direction.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

addSelect()

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

public addSelect(mixed ...$select) : $this
$qb = $conn->getQueryBuilder() ->select('u.id') ->addSelect('p.id') ->from('users', 'u') ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
Parameters
$select : mixed

The selection expression.

Tags
since
8.2.0
psalm-taint-sink

sql $select

Return values
$this

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) : $this
Parameters
$having : mixed

The restriction to append.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

andWhere()

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

public andWhere(mixed ...$where) : $this
Parameters
$where : mixed

The query restrictions.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

automaticTablePrefix()

Enable/disable automatic prefixing of table names with the oc_ prefix

public automaticTablePrefix(bool $enabled) : mixed
Parameters
$enabled : bool

If set to true table names will be prefixed with the owncloud database prefix automatically.

Tags
since
8.2.0

createFunction()

Creates a new function.

public createFunction(string $call) : IQueryFunction
Parameters
$call : string
Tags
warning

Column names inside the call have to be quoted beforehand. In most case you can use the IFunctionBuilder instead.

Example: $qb = $conn->getQueryBuilder(); $qb->select($qb->createFunction('COUNT()')) ->from('users', 'u') echo $qb->getSQL(); // SELECT COUNT() FROM users u $qb = $conn->getQueryBuilder(); $qb->select($qb->createFunction('COUNT(column)')) ->from('users', 'u') echo $qb->getSQL(); // SELECT COUNT(column) FROM users u

since
8.2.0
psalm-taint-sink

sql $call

Return values
IQueryFunction

createNamedParameter()

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

public createNamedParameter(mixed $value[, self::PARAM_* $type = self::PARAM_STR ][, string $placeHolder = null ]) : IParameter

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.

For more information see

Example: $value = 2; $q->eq( 'id', $q->bindValue( $value ) ); $stmt = $q->executeQuery(); // executed with 'id = 2'

Parameters
$value : mixed
$type : self::PARAM_* = self::PARAM_STR
$placeHolder : string = null

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

Tags
license

New BSD License

link
http://www.zetacomponents.org
since
8.2.0
psalm-taint-escape

sql

Return values
IParameter

createParameter()

Creates a new parameter

public createParameter(string $name) : IParameter

Example: $qb = $conn->getQueryBuilder(); $qb->select('u.*') ->from('users', 'u') ->where('u.username = ' . $qb->createParameter('name')) ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))

Parameters
$name : string
Tags
since
8.2.0
psalm-taint-escape

sql

Return values
IParameter

createPositionalParameter()

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

public createPositionalParameter(mixed $value[, self::PARAM_* $type = self::PARAM_STR ]) : IParameter

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.

Example: $qb = $conn->getQueryBuilder(); $qb->select('u.*') ->from('users', 'u') ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR)) ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))

Parameters
$value : mixed
$type : self::PARAM_* = self::PARAM_STR
Tags
since
8.2.0
psalm-taint-escape

sql

Return values
IParameter

delete()

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

public delete([mixed $delete = null ][, mixed $alias = null ]) : $this
Parameters
$delete : mixed = null

The table whose rows are subject to the deletion.

$alias : mixed = null

The table alias used in the constructed query.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

executeQuery()

Execute for select statements

public executeQuery([IDBConnection|null $connection = null ]) : IResult<string|int, S>
Parameters
$connection : IDBConnection|null = null

(optional) the connection to run the query against. since 30.0

Tags
inheritDoc
Attributes
#[Override]
Return values
IResult<string|int, S>

executeStatement()

Execute insert, update and delete statements

public executeStatement([IDBConnection|null $connection = null ]) : int
Parameters
$connection : IDBConnection|null = null

(optional) the connection to run the query against. since 30.0

Tags
since
22.0.0
throws
Exception
throws
RuntimeException

in case of usage with select query

Return values
int

the number of affected rows

expr()

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

public expr() : IExpressionBuilder

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

$qb = $conn->getQueryBuilder() ->select('u') ->from('users', 'u') ->where($qb->expr()->eq('u.id', 1));

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

Tags
since
8.2.0
Return values
IExpressionBuilder

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(mixed $from[, mixed $alias = null ]) : $this
Parameters
$from : mixed

The table.

$alias : mixed = null

The alias of the table.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

func()

Gets an FunctionBuilder used for object-oriented construction of query functions.

public func() : IFunctionBuilder

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

$qb = $conn->getQueryBuilder() ->select('u') ->from('users', 'u') ->where($qb->fun()->md5('u.id'));

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

Tags
since
12.0.0
Return values
IFunctionBuilder

getColumnName()

Returns the column name quoted and with table alias prefix as needed by the implementation

public getColumnName(string $column[, string $tableAlias = '' ]) : string
Parameters
$column : string
$tableAlias : string = ''
Tags
since
9.0.0
Return values
string

getFirstResult()

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

public getFirstResult() : int

Returns 0 if was not applied to this QueryBuilder.

Tags
since
8.2.0
Return values
int

The position of the first result.

getLastInsertId()

Used to get the id of the last inserted element

public getLastInsertId() : int
Tags
throws
BadMethodCallException

When being called before an insert query has been run.

since
9.0.0
Return values
int

getMaxResults()

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

public getMaxResults() : int|null

Returns NULL if was not applied to this query builder.

Tags
since
8.2.0
Return values
int|null

The maximum number of results.

getOutputColumns()

Get a list of column names that are expected in the query output

public getOutputColumns() : array<string|int, mixed>
Tags
since
30.0.0
Return values
array<string|int, mixed>

getParameter()

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

public getParameter(mixed $key) : mixed
Parameters
$key : mixed

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

Tags
since
8.2.0
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>
Tags
since
8.2.0
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(mixed $key) : mixed
Parameters
$key : mixed

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

Tags
since
8.2.0
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>
Tags
since
8.2.0
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

This function is going to be removed with the next Doctrine/DBAL update and we can not fix this in our wrapper. Please track the details you need, outside the object.

Parameters
$queryPartName : string
Tags
since
8.2.0

getQueryParts()

Gets all query parts.

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

This function is going to be removed with the next Doctrine/DBAL update and we can not fix this in our wrapper. Please track the details you need, outside the object.

Tags
since
8.2.0
Return values
array<string|int, mixed>

getSQL()

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

public getSQL() : string
$qb = $conn->getQueryBuilder() ->select('u') ->from('User', 'u') echo $qb->getSQL(); // SELECT u FROM User u
Tags
since
8.2.0
Return values
string

The SQL query string.

getState()

Gets the state of this query builder instance.

public getState() : int

This function is going to be removed with the next Doctrine/DBAL update and we can not fix this in our wrapper.

Tags
since
8.2.0
Return values
int

Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.

getTableName()

Returns the table name quoted and with database prefix as needed by the implementation.

public getTableName(string|IQueryFunction $table) : string

If a query function is passed the function is casted to string, this allows passing functions as sub-queries for join expression.

Parameters
$table : string|IQueryFunction
Tags
since
9.0.0
since
24.0.0

accepts IQueryFunction as parameter

Return values
string

getType()

Gets the type of the currently built query.

public getType() : int
Tags
since
8.2.0
Return values
int

groupBy()

Specifies a grouping over the results of the query.

public groupBy(mixed ...$groupBys) : $this
Parameters
$groupBys : mixed

The grouping expression.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

having()

Specifies a restriction over the groups of the query.

public having(mixed ...$having) : $this
Parameters
$having : mixed

The restriction over the groups.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

hintShardKey()

Provide a hint for the shard key for queries where this can't be detected otherwise

public hintShardKey(string $column, mixed $value[, bool $overwrite = false ]) : $this
Parameters
$column : string
$value : mixed
$overwrite : bool = false
Tags
inheritDoc
Attributes
#[Override]
Return values
$this

innerJoin()

Creates and adds a join to the query.

public innerJoin(mixed $fromAlias, mixed $join, mixed $alias[, mixed $condition = null ]) : $this
Parameters
$fromAlias : mixed

The alias that points to a from clause.

$join : mixed

The table name to join.

$alias : mixed

The alias of the join table.

$condition : mixed = null

The condition for the join.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

insert()

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

public insert([mixed $insert = null ]) : $this
Parameters
$insert : mixed = null

The table into which the rows should be inserted.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

join()

Creates and adds a join to the query.

public join(mixed $fromAlias, mixed $join, mixed $alias[, mixed $condition = null ]) : $this
Parameters
$fromAlias : mixed

The alias that points to a from clause.

$join : mixed

The table name to join.

$alias : mixed

The alias of the join table.

$condition : mixed = null

The condition for the join.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

leftJoin()

Creates and adds a left join to the query.

public leftJoin(mixed $fromAlias, mixed $join, mixed $alias[, mixed $condition = null ]) : $this
Parameters
$fromAlias : mixed

The alias that points to a from clause.

$join : mixed

The table name to join.

$alias : mixed

The alias of the join table.

$condition : mixed = null

The condition for the join.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

orderBy()

Specifies an ordering for the query results.

public orderBy(mixed $sort[, mixed $order = null ]) : $this
Parameters
$sort : mixed

The ordering expression.

$order : mixed = null

The ordering direction.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

orHaving()

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

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

The restriction to add.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

orWhere()

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

public orWhere(mixed ...$where) : $this
Parameters
$where : mixed

The WHERE statement.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

prefixTableName()

Returns the table name with database prefix as needed by the implementation

public prefixTableName(string $table) : string
Parameters
$table : string
Tags
since
30.0.0
Return values
string

resetQueryPart()

Resets a single SQL part.

public resetQueryPart(mixed $queryPartName) : $this
Parameters
$queryPartName : mixed
Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

resetQueryParts()

Resets SQL parts.

public resetQueryParts([mixed $queryPartNames = null ]) : $this
Parameters
$queryPartNames : mixed = null
Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

rightJoin()

Creates and adds a right join to the query.

public rightJoin(mixed $fromAlias, mixed $join, mixed $alias[, mixed $condition = null ]) : $this
Parameters
$fromAlias : mixed

The alias that points to a from clause.

$join : mixed

The table name to join.

$alias : mixed

The alias of the join table.

$condition : mixed = null

The condition for the join.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

runAcrossAllShards()

Set the query to run across all shards if sharding is enabled.

public runAcrossAllShards() : $this
Tags
inheritDoc
Attributes
#[Override]
Return values
$this

select()

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

public select(mixed ...$selects) : $this

Replaces any previously specified selections, if any.

$qb = $conn->getQueryBuilder() ->select('u.id', 'p.id') ->from('users', 'u') ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
Parameters
$selects : mixed

The selection expressions.

Tags
since
8.2.0
psalm-taint-sink

sql $selects

Return values
$this

This QueryBuilder instance.

selectAlias()

Specifies an item that is to be returned with a different name in the query result.

public selectAlias(mixed $select, NewS $alias) : $this
Parameters
$select : mixed
$alias : NewS
Tags
inheritDoc
template
psalm-this-out

self<S|NewS>

note

Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439

Attributes
#[Override]
Return values
$this

selectColumns()

public selectColumns(NewS ...$columns) : $this
Parameters
$columns : NewS

The columns to select. They are not allowed to contain table names or aliases, or asterisks. Use self::selectAlias() for that.

Tags
template
psalm-this-out

self<S|NewS>

since
34.0.0
note

Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439

Return values
$this

selectColumnsDistinct()

public selectColumnsDistinct(NewS ...$columns) : $this
Parameters
$columns : NewS

The columns to select distinct. They are not allowed to contain table names or aliases, or asterisks. Use self::selectAlias() for that.

Tags
template
psalm-this-out

self<S|NewS>

since
34.0.0
note

Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439

Return values
$this

selectDistinct()

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

public selectDistinct(mixed $select) : $this
$qb = $conn->getQueryBuilder() ->selectDistinct('type') ->from('users');
Parameters
$select : mixed

The selection expressions.

Tags
since
9.0.0
psalm-taint-sink

sql $select

Return values
$this

This QueryBuilder instance.

set()

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

public set(mixed $key, mixed $value) : $this
Parameters
$key : mixed

The column to set.

$value : mixed

The value, expression, placeholder, etc.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

setFirstResult()

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

public setFirstResult(mixed $firstResult) : $this
Parameters
$firstResult : mixed

The first result to return.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

setMaxResults()

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

public setMaxResults(mixed $maxResults) : $this
Parameters
$maxResults : mixed

The maximum number of results to retrieve.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

setParameter()

Sets a query parameter for the query being constructed.

public setParameter(mixed $key, mixed $value[, mixed $type = null ]) : $this
Parameters
$key : mixed

The parameter position or name.

$value : mixed

The parameter value.

$type : mixed = null

One of the IQueryBuilder::PARAM_* constants.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

setParameters()

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

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

The query parameters to set.

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

The query parameters types to set.

Tags
inheritDoc
Attributes
#[Override]
Return values
$this

setValue()

Sets a value for a column in an insert query.

public setValue(mixed $column, mixed $value) : $this
Parameters
$column : mixed

The column into which the value should be inserted.

$value : mixed

The value that should be inserted into the column.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

update()

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

public update([mixed $update = null ][, mixed $alias = null ]) : $this
Parameters
$update : mixed = null

The table whose rows are subject to the update.

$alias : mixed = null

The table alias used in the constructed query.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

values()

Specifies values for an insert query indexed by column names.

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

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

Tags
inheritDoc
Attributes
#[Override]
Return values
$this

where()

Specifies one or more restrictions to the query result.

public where(mixed ...$predicates) : $this
Parameters
$predicates : mixed

The restriction predicates.

Tags
inheritDoc
psalm-suppress

MissingParamType

Attributes
#[Override]
Return values
$this

        
On this page

Search results