IQueryBuilder¶
-
interface
OCP\DB\QueryBuilder\
IQueryBuilder
¶ - This class provides a wrapper around Doctrine’s QueryBuilder
Implemented by: OC\DB\QueryBuilder\QueryBuilder
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#41
Constants¶
-
PARAM_NULL = \PDO::PARAM_NULL
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#46 Since: 9.0.0
-
PARAM_BOOL = \PDO::PARAM_BOOL
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#50 Since: 9.0.0
-
PARAM_INT = \PDO::PARAM_INT
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#54 Since: 9.0.0
-
PARAM_STR = \PDO::PARAM_STR
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#58 Since: 9.0.0
-
PARAM_LOB = \PDO::PARAM_LOB
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#62 Since: 9.0.0
-
PARAM_DATE = datetime
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#66 Since: 9.0.0
-
PARAM_INT_ARRAY = \Doctrine\DBAL\Connection::PARAM_INT_ARRAY
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#71 Since: 9.0.0
-
PARAM_STR_ARRAY = \Doctrine\DBAL\Connection::PARAM_STR_ARRAY
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#75 Since: 9.0.0
Methods¶
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
automaticTablePrefix
($enabled)¶ - Enable/disable automatic prefixing of table names with the oc_ prefix
Source: Parameters: - $enabled (bool) If set to true table names will be prefixed with the
owncloud database prefix automatically.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
expr
()¶ - Gets an ExpressionBuilder used for object-oriented construction of query expressions.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 expressionbuilder object in a local variable.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#104 Returns: \OCP\DB\QueryBuilder\IExpressionBuilder
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
func
()¶ - Gets an FunctionBuilder used for object-oriented construction of query functions.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 functionbuilder object in a local variable.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#123 Returns: \OCP\DB\QueryBuilder\IFunctionBuilder
Since: 12.0.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getType
()¶ - Gets the type of the currently built query.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#131 Returns: int Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getConnection
()¶ - Gets the associated DBAL Connection for this query builder.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#139 Returns: \OCP\IDBConnection
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getState
()¶ - Gets the state of this query builder instance.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#147 Returns: int Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
execute
()¶ - Executes this query using the bound parameters and their types.Uses {@see \OCP\DB\QueryBuilder\Connection::executeQuery} for select statements and {@see \OCP\DB\QueryBuilder\Connection::executeStatement}for insert, update and delete statements.Warning: until Nextcloud 20, this method could return a \Doctrine\DBAL\Driver\Statement but sincethat interface changed in a breaking way the adapter \OCP\DB\QueryBuilder\IStatement is returnedto bridge old code to the new API
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#164 Returns: \OCP\DB\IResult
| intThrows: \OCP\DB\Exception
since 21.0.0Since: 8.2.0 Deprecated: 22.0.0 Use executeQuery or executeUpdate
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
executeQuery
()¶ - Execute for select statements
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#175 Returns: \OCP\DB\IResult
Since: 22.0.0 Throws: \OCP\DB\Exception
Throws: \RuntimeException
in case of usage with non select queryThrows: \OCP\DB\Exception
Throws: \RuntimeException
in case of usage with non select query
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
executeStatement
()¶ - Execute insert, update and delete statements
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#186 Returns: int the number of affected rows Since: 22.0.0 Throws: \OCP\DB\Exception
Throws: \RuntimeException
in case of usage with select queryThrows: \OCP\DB\Exception
Throws: \RuntimeException
in case of usage with select query
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getSQL
()¶ - Gets the complete SQL string formed by the current specifications of this QueryBuilder.<code>$qb = $conn->getQueryBuilder()->select(‘u’)->from(‘User’, ‘u’)echo $qb->getSQL(); // SELECT u FROM User u</code>
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#201 Returns: string The SQL query string. Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
setParameter
($key, $value, $type=null)¶ - Sets a query parameter for the query being constructed.<code>$qb = $conn->getQueryBuilder()->select(‘u’)->from(‘users’, ‘u’)->where(‘u.id = :user_id’)->setParameter(‘:user_id’, 1);</code>
Source: Parameters: - $key (string | int) The parameter position or name.
- $value (mixed) The parameter value.
- $type (string | null | int) One of the IQueryBuilder::PARAM_* constants.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
setParameters
($params, $types=[])¶ - Sets a collection of query parameters for the query being constructed.<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>
Source: Parameters: - $params (array) The query parameters to set.
- $types (array) The query parameters types to set.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getParameters
()¶ - Gets all defined query parameters for the query being constructed indexed by parameter index or name.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#251 Returns: array The currently defined query parameters indexed by parameter index or name. Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getParameter
($key)¶ - Gets a (previously set) query parameter of the query being constructed.
Source: Parameters: - $key (mixed) The key (index or name) of the bound parameter.
Returns: mixed The value of the bound parameter.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getParameterTypes
()¶ - Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#269 Returns: array The currently defined query parameter types indexed by parameter index or name. Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getParameterType
($key)¶ - Gets a (previously set) query parameter type of the query being constructed.
Source: Parameters: - $key (mixed) The key (index or name) of the bound parameter type.
Returns: mixed The value of the bound parameter type.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
setFirstResult
($firstResult)¶ - Sets the position of the first result to retrieve (the “offset”).
Source: Parameters: - $firstResult (int) The first result to return.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getFirstResult
()¶ - Gets the position of the first result the query object was set to retrieve (the “offset”).Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#298 Returns: int The position of the first result. Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
setMaxResults
($maxResults)¶ - Sets the maximum number of results to retrieve (the “limit”).
Source: Parameters: - $maxResults (int) The maximum number of results to retrieve.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getMaxResults
()¶ - Gets the maximum number of results the query object was set to retrieve (the “limit”).Returns NULL if {@link setMaxResults} was not applied to this query builder.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#317 Returns: int | null The maximum number of results. Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
select
(...$selects)¶ - Specifies an item that is to be returned in the query result.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>
Source: Parameters: - $selects (mixed) The selection expressions.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
selectAlias
($select, $alias)¶ - Specifies an item that is to be returned with a different name in the query result.<code>$qb = $conn->getQueryBuilder()->selectAlias(‘u.id’, ‘user_id’)->from(‘users’, ‘u’)->leftJoin(‘u’, ‘phonenumbers’, ‘p’, ‘u.id = p.user_id’);</code>
Source: Parameters: - $select (mixed) The selection expressions.
- $alias (string) The column alias used in the constructed query.
Returns: $this This QueryBuilder instance.
Since: 8.2.1
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
selectDistinct
($select)¶ - Specifies an item that is to be returned uniquely in the query result.<code>$qb = $conn->getQueryBuilder()->selectDistinct(‘type’)->from(‘users’);</code>
Source: Parameters: - $select (mixed) The selection expressions.
Returns: $this This QueryBuilder instance.
Since: 9.0.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
addSelect
(...$select)¶ - Adds an item that is to be returned in the query result.<code>$qb = $conn->getQueryBuilder()->select(‘u.id’)->addSelect(‘p.id’)->from(‘users’, ‘u’)->leftJoin(‘u’, ‘phonenumbers’, ‘u.id = p.user_id’);</code>
Source: Parameters: - $select (mixed) The selection expression.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
delete
($delete=null, $alias=null)¶ - Turns the query being built into a bulk delete query that ranges overa certain table.<code>$qb = $conn->getQueryBuilder()->delete(‘users’, ‘u’)->where(‘u.id = :user_id’);->setParameter(‘:user_id’, 1);</code>
Source: Parameters: - $delete (string) The table whose rows are subject to the deletion.
- $alias (string) The table alias used in the constructed query.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
update
($update=null, $alias=null)¶ - Turns the query being built into a bulk update query that ranges overa certain table<code>$qb = $conn->getQueryBuilder()->update(‘users’, ‘u’)->set(‘u.password’, md5(‘password’))->where(‘u.id = ?’);</code>
Source: Parameters: - $update (string) The table whose rows are subject to the update.
- $alias (string) The table alias used in the constructed query.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
insert
($insert=null)¶ - Turns the query being built into an insert query that inserts intoa certain table<code>$qb = $conn->getQueryBuilder()->insert(‘users’)->values(array(‘name’ => ‘?’,‘password’ => ‘?’));</code>
Source: Parameters: - $insert (string) The table into which the rows should be inserted.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
from
($from, $alias=null)¶ - Creates and adds a query root corresponding to the table identified by thegiven alias, forming a cartesian product with any existing query roots.<code>$qb = $conn->getQueryBuilder()->select(‘u.id’)->from(‘users’, ‘u’)</code>
Source: Parameters: - $from (string) The table.
- $alias (string | null) The alias of the table.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
join
($fromAlias, $join, $alias, $condition=null)¶ - Creates and adds a join to the query.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->join(‘u’, ‘phonenumbers’, ‘p’, ‘p.is_primary = 1’);</code>
Source: 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 |
\OCP\DB\QueryBuilder\ICompositeExpression
| null) The condition for the join.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
innerJoin
($fromAlias, $join, $alias, $condition=null)¶ - Creates and adds a join to the query.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->innerJoin(‘u’, ‘phonenumbers’, ‘p’, ‘p.is_primary = 1’);</code>
Source: 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 |
\OCP\DB\QueryBuilder\ICompositeExpression
| null) The condition for the join.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
leftJoin
($fromAlias, $join, $alias, $condition=null)¶ - Creates and adds a left join to the query.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->leftJoin(‘u’, ‘phonenumbers’, ‘p’, ‘p.is_primary = 1’);</code>
Source: 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 |
\OCP\DB\QueryBuilder\ICompositeExpression
| null) The condition for the join.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
rightJoin
($fromAlias, $join, $alias, $condition=null)¶ - Creates and adds a right join to the query.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->rightJoin(‘u’, ‘phonenumbers’, ‘p’, ‘p.is_primary = 1’);</code>
Source: 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 |
\OCP\DB\QueryBuilder\ICompositeExpression
| null) The condition for the join.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
set
($key, $value)¶ - Sets a new value for a column in a bulk update query.<code>$qb = $conn->getQueryBuilder()->update(‘users’, ‘u’)->set(‘u.password’, md5(‘password’))->where(‘u.id = ?’);</code>
Source: Parameters: - $key (string) The column to set.
- $value (
OCP\DB\QueryBuilder\ILiteral
|\OCP\DB\QueryBuilder\IParameter
|\OCP\DB\QueryBuilder\IQueryFunction
| string) The value, expression, placeholder, etc.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
where
(...$predicates)¶ - Specifies one or more restrictions to the query result.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>
Source: Parameters: - $predicates (mixed) The restriction predicates.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
andWhere
(...$where)¶ - Adds one or more restrictions to the query results, forming a logicalconjunction with any previously specified restrictions.<code>$qb = $conn->getQueryBuilder()->select(‘u’)->from(‘users’, ‘u’)->where(‘u.username LIKE ?’)->andWhere(‘u.is_active = 1’);</code>
Source: Parameters: - $where (mixed) The query restrictions.
Returns: $this This QueryBuilder instance.
See: \OCP\DB\QueryBuilder\where()
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
orWhere
(...$where)¶ - Adds one or more restrictions to the query results, forming a logicaldisjunction with any previously specified restrictions.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->where(‘u.id = 1’)->orWhere(‘u.id = 2’);</code>
Source: Parameters: - $where (mixed) The WHERE statement.
Returns: $this This QueryBuilder instance.
See: \OCP\DB\QueryBuilder\where()
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
groupBy
(...$groupBys)¶ - Specifies a grouping over the results of the query.Replaces any previously specified groupings, if any.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->groupBy(‘u.id’);</code>
Source: Parameters: - $groupBys (mixed) The grouping expression.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
addGroupBy
(...$groupBy)¶ - Adds a grouping expression to the query.<code>$qb = $conn->getQueryBuilder()->select(‘u.name’)->from(‘users’, ‘u’)->groupBy(‘u.lastLogin’);->addGroupBy(‘u.createdAt’)</code>
Source: Parameters: - $groupBy (mixed) The grouping expression.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
setValue
($column, $value)¶ - Sets a value for a column in an insert query.<code>$qb = $conn->getQueryBuilder()->insert(‘users’)->values(array(‘name’ => ‘?’))->setValue(‘password’, ‘?’);</code>
Source: Parameters: - $column (string) The column into which the value should be inserted.
- $value (
OCP\DB\QueryBuilder\IParameter
| string) The value that should be inserted into the column.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
values
($values)¶ - Specifies values for an insert query indexed by column names.Replaces any previous values, if any.<code>$qb = $conn->getQueryBuilder()->insert(‘users’)->values(array(‘name’ => ‘?’,‘password’ => ‘?’));</code>
Source: Parameters: - $values (array) The values to specify for the insert query indexed by column names.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
having
(...$having)¶ - Specifies a restriction over the groups of the query.Replaces any previous having restrictions, if any.
Source: Parameters: - $having (mixed) The restriction over the groups.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
andHaving
(...$having)¶ - Adds a restriction over the groups of the query, forming a logicalconjunction with any existing having restrictions.
Source: Parameters: - $having (mixed) The restriction to append.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
orHaving
(...$having)¶ - Adds a restriction over the groups of the query, forming a logicaldisjunction with any existing having restrictions.
Source: Parameters: - $having (mixed) The restriction to add.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
orderBy
($sort, $order=null)¶ - Specifies an ordering for the query results.Replaces any previously specified orderings, if any.
Source: Parameters: - $sort (string) The ordering expression.
- $order (string) The ordering direction.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
addOrderBy
($sort, $order=null)¶ - Adds an ordering to the query results.
Source: Parameters: - $sort (string) The ordering expression.
- $order (string) The ordering direction.
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getQueryPart
($queryPartName)¶ - Gets a query part by its name.
Source: Parameters: - $queryPartName (string)
Returns: mixed
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getQueryParts
()¶ - Gets all query parts.
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#855 Returns: array Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
resetQueryParts
($queryPartNames=null)¶ - Resets SQL parts.
Source: Parameters: - $queryPartNames (array | null)
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
resetQueryPart
($queryPartName)¶ - Resets a single SQL part.
Source: Parameters: - $queryPartName (string)
Returns: $this This QueryBuilder instance.
Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
createNamedParameter
($value, $type=self::PARAM_STR, $placeHolder=null)¶ - Creates a new named parameter and bind the value $value to it.This method provides a shortcut for PDOStatement::bindValuewhen using prepared statements.The parameter $value specifies the value that you want to bind. If$placeholder is not provided bindValue() will automatically create aplaceholder for you. An automatic placeholder will be of the name‘:dcValue1’, ‘:dcValue2’ etc.For more information see {@link https://www.php.net/pdostatement-bindparam}Example:<code>$value = 2;$q->eq( ‘id’, $q->bindValue( $value ) );$stmt = $q->executeQuery(); // executed with ‘id = 2’</code>
Source: Parameters: - $value (mixed)
- $type (mixed)
- $placeHolder (string) The name to bind with. The string must start with a colon ‘:’.
License: New BSD License
Returns: Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
createPositionalParameter
($value, $type=self::PARAM_STR)¶ - Creates a new positional parameter and bind the given value to it.Attention: If you are using positional parameters with the query builder you haveto be very careful to bind all parameters in the order they appear in the SQLstatement , otherwise they get bound in the wrong order which can lead to seriousbugs 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>
Source: Parameters: - $value (mixed)
- $type (int)
Returns: Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
createParameter
($name)¶ - Creates a new parameterExample:<code>$qb = $conn->getQueryBuilder();$qb->select(‘u.*’)->from(‘users’, ‘u’)->where(‘u.username = ‘ . $qb->createParameter(‘name’))->setParameter(‘name’, ‘Bar’, IQueryBuilder::PARAM_STR))</code>
Source: Parameters: - $name (string)
Returns: Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
createFunction
($call)¶ - Creates a new functionAttention: Column names inside the call have to be quoted before handExample:<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>
Source: Parameters: - $call (string)
Returns: Since: 8.2.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getLastInsertId
()¶ - Used to get the id of the last inserted element
Source: lib/public/DB/QueryBuilder/IQueryBuilder.php#993 Returns: int Throws: \BadMethodCallException
When being called before an insert query has been run.Since: 9.0.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getTableName
($table)¶ - Returns the table name quoted and with database prefix as needed by the implementation
Source: Parameters: - $table (string)
Returns: string
Since: 9.0.0
-
public
OCP\DB\QueryBuilder\IQueryBuilder::
getColumnName
($column, $tableAlias="")¶ - Returns the column name quoted and with table alias prefix as needed by the implementation
Source: Parameters: - $column (string)
- $tableAlias (string)
Returns: string
Since: 9.0.0