Nextcloud PHP API (stable18)

IQueryBuilder

This class provides a wrapper around Doctrine's QueryBuilder

Tags
since
8.2.0

Table of Contents

PARAM_BOOL  = PDO::PARAM_BOOL
PARAM_DATE  = 'datetime'
PARAM_INT  = PDO::PARAM_INT
PARAM_INT_ARRAY  = DoctrineDBALConnection::PARAM_INT_ARRAY
PARAM_LOB  = PDO::PARAM_LOB
PARAM_NULL  = PDO::PARAM_NULL
PARAM_STR  = PDO::PARAM_STR
PARAM_STR_ARRAY  = DoctrineDBALConnection::PARAM_STR_ARRAY
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.
execute()  : Statement|int
Executes this query using the bound parameters and their types.
expr()  : IExpressionBuilder
Gets an ExpressionBuilder used for object-oriented construction of query expressions.
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
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
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
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
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.
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.
resetQueryPart()  : $this
Resets a single SQL part.
resetQueryParts()  : $this
Resets SQL parts.
rightJoin()  : $this
Creates and adds a right join to the query.
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.
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

PARAM_BOOL

public mixed PARAM_BOOL = PDO::PARAM_BOOL
Tags
since
9.0.0

PARAM_DATE

public mixed PARAM_DATE = 'datetime'
Tags
since
9.0.0

PARAM_INT

public mixed PARAM_INT = PDO::PARAM_INT
Tags
since
9.0.0

PARAM_INT_ARRAY

public mixed PARAM_INT_ARRAY = DoctrineDBALConnection::PARAM_INT_ARRAY
Tags
since
9.0.0

PARAM_LOB

public mixed PARAM_LOB = PDO::PARAM_LOB
Tags
since
9.0.0

PARAM_NULL

public mixed PARAM_NULL = PDO::PARAM_NULL
Tags
since
9.0.0

PARAM_STR

public mixed PARAM_STR = PDO::PARAM_STR
Tags
since
9.0.0

PARAM_STR_ARRAY

public mixed PARAM_STR_ARRAY = DoctrineDBALConnection::PARAM_STR_ARRAY
Tags
since
9.0.0

Methods

addGroupBy()

Adds a grouping expression to the query.

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

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->groupBy('u.lastLogin'); ->addGroupBy('u.createdAt') </code>

Parameters
$groupBy : mixed

The grouping expression.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

addOrderBy()

Adds an ordering to the query results.

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

The ordering expression.

$order : string = null

The ordering direction.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

addSelect()

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

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

<code> $qb = $conn->getQueryBuilder() ->select('u.id') ->addSelect('p.id') ->from('users', 'u') ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id'); </code>

Parameters
$select : mixed

The selection expression.

Tags
since
8.2.0
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
since
8.2.0
Return values
$this —

This QueryBuilder instance.

andWhere()

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

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

<code> $qb = $conn->getQueryBuilder() ->select('u') ->from('users', 'u') ->where('u.username LIKE ?') ->andWhere('u.is_active = 1'); </code>

Parameters
$where : mixed

The query restrictions.

Tags
see
where()
since
8.2.0
Return values
$this —

This QueryBuilder instance.

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
Return values
mixed —

createFunction()

Creates a new function

public createFunction(string $call) : IQueryFunction

Attention: Column names inside the call have to be quoted before hand

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

Parameters
$call : string
Tags
since
8.2.0
Return values
IQueryFunction —

createNamedParameter()

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

public createNamedParameter(mixed $value[, mixed $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 http://php.net/pdostatement-bindparam

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

Parameters
$value : mixed
$type : mixed = 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
Return values
IParameter —

createParameter()

Creates a new parameter

public createParameter(string $name) : IParameter

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

Parameters
$name : string
Tags
since
8.2.0
Return values
IParameter —

createPositionalParameter()

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

public createPositionalParameter(mixed $value[, int $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: <code> $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)) </code>

Parameters
$value : mixed
$type : int = self::PARAM_STR
Tags
since
8.2.0
Return values
IParameter —

delete()

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

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

<code> $qb = $conn->getQueryBuilder() ->delete('users', 'u') ->where('u.id = :user_id'); ->setParameter(':user_id', 1); </code>

Parameters
$delete : string = null

The table whose rows are subject to the deletion.

$alias : string = null

The table alias used in the constructed query.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

execute()

Executes this query using the bound parameters and their types.

public execute() : Statement|int

Uses \OCP\DB\QueryBuilder\Connection::executeQuery for select statements and \OCP\DB\QueryBuilder\Connection::executeUpdate for insert, update and delete statements.

Tags
since
8.2.0
Return values
Statement|int —

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:

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

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

<code> $qb = $conn->getQueryBuilder() ->select('u.id') ->from('users', 'u') </code>

Parameters
$from : string

The table.

$alias : string|null = null

The alias of the table.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

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:

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

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 NULL if setFirstResult 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

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

Tags
since
8.2.0
Return values
int —

The maximum number of results.

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
Tags
since
8.2.0
Return values
array —

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
Tags
since
8.2.0
Return values
array —

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
Tags
since
8.2.0
Return values
mixed —

getQueryParts()

Gets all query parts.

public getQueryParts() : array
Tags
since
8.2.0
Return values
array —

getSQL()

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

public getSQL() : string

<code> $qb = $conn->getQueryBuilder() ->select('u') ->from('User', 'u') echo $qb->getSQL(); // SELECT u FROM User u </code>

Tags
since
8.2.0
Return values
string —

The SQL query string.

getState()

Gets the state of this query builder instance.

public getState() : int
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 $table) : string
Parameters
$table : string
Tags
since
9.0.0
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

Replaces any previously specified groupings, if any.

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->groupBy('u.id'); </code>

Parameters
$groupBys : mixed

The grouping expression.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

having()

Specifies a restriction over the groups of the query.

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

Replaces any previous having restrictions, if any.

Parameters
$having : mixed

The restriction over the groups.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

innerJoin()

Creates and adds a join to the query.

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

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); </code>

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

The condition for the join.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

insert()

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

public insert([string $insert = null ]) : $this

<code> $qb = $conn->getQueryBuilder() ->insert('users') ->values( array( 'name' => '?', 'password' => '?' ) ); </code>

Parameters
$insert : string = null

The table into which the rows should be inserted.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

join()

Creates and adds a join to the query.

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

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1'); </code>

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

The condition for the join.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

leftJoin()

Creates and adds a left join to the query.

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

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); </code>

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

The condition for the join.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

orderBy()

Specifies an ordering for the query results.

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

Replaces any previously specified orderings, if any.

Parameters
$sort : string

The ordering expression.

$order : string = null

The ordering direction.

Tags
since
8.2.0
Return values
$this —

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

The restriction to add.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

orWhere()

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

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

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->where('u.id = 1') ->orWhere('u.id = 2'); </code>

Parameters
$where : mixed

The WHERE statement.

Tags
see
where()
since
8.2.0
Return values
$this —

This QueryBuilder instance.

resetQueryPart()

Resets a single SQL part.

public resetQueryPart(string $queryPartName) : $this
Parameters
$queryPartName : string
Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

resetQueryParts()

Resets SQL parts.

public resetQueryParts([array|null $queryPartNames = null ]) : $this
Parameters
$queryPartNames : array|null = null
Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

rightJoin()

Creates and adds a right join to the query.

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

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); </code>

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

The condition for the join.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

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.

<code> $qb = $conn->getQueryBuilder() ->select('u.id', 'p.id') ->from('users', 'u') ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); </code>

Parameters
$selects : mixed

The selection expressions.

Tags
since
8.2.0
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, string $alias) : $this

<code> $qb = $conn->getQueryBuilder() ->selectAlias('u.id', 'user_id') ->from('users', 'u') ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); </code>

Parameters
$select : mixed

The selection expressions.

$alias : string

The column alias used in the constructed query.

Tags
since
8.2.1
Return values
$this —

This QueryBuilder instance.

selectDistinct()

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

public selectDistinct(mixed $select) : $this

<code> $qb = $conn->getQueryBuilder() ->selectDistinct('type') ->from('users'); </code>

Parameters
$select : mixed

The selection expressions.

Tags
since
9.0.0
Return values
$this —

This QueryBuilder instance.

set()

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

public set(string $key, string $value) : $this

<code> $qb = $conn->getQueryBuilder() ->update('users', 'u') ->set('u.password', md5('password')) ->where('u.id = ?'); </code>

Parameters
$key : string

The column to set.

$value : string

The value, expression, placeholder, etc.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

setFirstResult()

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

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

The first result to return.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

setMaxResults()

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

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

The maximum number of results to retrieve.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

setParameter()

Sets a query parameter for the query being constructed.

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

<code> $qb = $conn->getQueryBuilder() ->select('u') ->from('users', 'u') ->where('u.id = :user_id') ->setParameter(':user_id', 1); </code>

Parameters
$key : string|int

The parameter position or name.

$value : mixed

The parameter value.

$type : string|null|int = null

One of the IQueryBuilder::PARAM_* constants.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

setParameters()

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

public setParameters(array $params[, array $types = array() ]) : $this

<code> $qb = $conn->getQueryBuilder() ->select('u') ->from('users', 'u') ->where('u.id = :user_id1 OR u.id = :user_id2') ->setParameters(array( ':user_id1' => 1, ':user_id2' => 2 )); </code>

Parameters
$params : array

The query parameters to set.

$types : array = array()

The query parameters types to set.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

setValue()

Sets a value for a column in an insert query.

public setValue(string $column, string $value) : $this

<code> $qb = $conn->getQueryBuilder() ->insert('users') ->values( array( 'name' => '?' ) ) ->setValue('password', '?'); </code>

Parameters
$column : string

The column into which the value should be inserted.

$value : string

The value that should be inserted into the column.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

update()

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

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

<code> $qb = $conn->getQueryBuilder() ->update('users', 'u') ->set('u.password', md5('password')) ->where('u.id = ?'); </code>

Parameters
$update : string = null

The table whose rows are subject to the update.

$alias : string = null

The table alias used in the constructed query.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

values()

Specifies values for an insert query indexed by column names.

public values(array $values) : $this

Replaces any previous values, if any.

<code> $qb = $conn->getQueryBuilder() ->insert('users') ->values( array( 'name' => '?', 'password' => '?' ) ); </code>

Parameters
$values : array

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

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

where()

Specifies one or more restrictions to the query result.

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

Replaces any previously specified restrictions, if any.

<code> $qb = $conn->getQueryBuilder() ->select('u.name') ->from('users', 'u') ->where('u.id = ?');

// You can optionally programatically build and/or expressions
$qb = $conn->getQueryBuilder();

$or = $qb->expr()->orx();
$or->add($qb->expr()->eq('u.id', 1));
$or->add($qb->expr()->eq('u.id', 2));

$qb->update('users', 'u')
    ->set('u.password', md5('password'))
    ->where($or);

</code>

Parameters
$predicates : mixed

The restriction predicates.

Tags
since
8.2.0
Return values
$this —

This QueryBuilder instance.

Search results