|
MediaWiki master
|
Build UPDATE queries with a fluent interface. More...
Inherits Wikimedia\Rdbms\IWriteQueryBuilder.

Public Member Functions | ||||
| __construct (IDatabase $db) | ||||
| Only for use in subclasses. | ||||
| andSet ( $set) | ||||
| Add set values to the query. | ||||
| andWhere ( $conds) | ||||
| Add conditions to the query. | ||||
| caller ( $fname) | ||||
Set the method name to be included in an SQL comment.
| ||||
| conds ( $conds) | ||||
| Add conditions to the query. | ||||
| connection (IDatabase $db) | ||||
Change the IDatabase object the query builder is bound to.The specified IDatabase will subsequently be used to execute the query.
| ||||
| execute () | ||||
| Run the constructed query. | ||||
| getQueryInfo () | ||||
Get an associative array describing the query in terms of its raw parameters to the counter-part method in Database object.This can be used to interface with legacy code.
| ||||
| ignore () | ||||
| Enable the IGNORE option. | ||||
| option ( $name, $value=null) | ||||
| Manually set an option in the $options array to be passed to IDatabase::update() | ||||
| options (array $options) | ||||
| Manually set multiple options in the $options array to be passed to IDatabase::update(). | ||||
| queryInfo ( $info) | ||||
Set the query parameters to the given values, appending to the values which were already set.This can be used to interface with legacy code. If a key is omitted, the previous value will be retained.The parameters must be formatted as required by the counter-part method in Database object.
| ||||
| set ( $set) | ||||
| Add SET part to the query. | ||||
| table ( $table) | ||||
| Manually set the table name to be passed to IDatabase::update() | ||||
| update (string $table) | ||||
| Set table for the query. | ||||
| where ( $conds) | ||||
| Add conditions to the query. | ||||
Protected Attributes | |
| IDatabase | $db |
| array | $options = [] |
| The options to be passed to IDatabase::update() | |
Build UPDATE queries with a fluent interface.
Each query builder object must be used for a single database query only, and not be reused afterwards. To run multiple similar queries, you can create a query builder to set up most of your query, which you can use as a "template" to clone. You can then modify the cloned object for each individual query.
Definition at line 21 of file UpdateQueryBuilder.php.
| Wikimedia\Rdbms\UpdateQueryBuilder::__construct | ( | IDatabase | $db | ) |
Only for use in subclasses.
To create a UpdateQueryBuilder instance, use $db->newUpdateQueryBuilder() instead.
Definition at line 53 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\$db.
| Wikimedia\Rdbms\UpdateQueryBuilder::andSet | ( | $set | ) |
Add set values to the query.
Alias for set().
| string|array<string,?scalar|RawSQLValue>|array<int,string> | $set |
Definition at line 270 of file UpdateQueryBuilder.php.
| Wikimedia\Rdbms\UpdateQueryBuilder::andWhere | ( | $conds | ) |
Add conditions to the query.
Alias for where().
| string|IExpression|array<string,?scalar|non-empty-array<int,?scalar>|RawSQLValue>|array<int,string|IExpression> | $conds |
Definition at line 210 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\where().
| Wikimedia\Rdbms\UpdateQueryBuilder::caller | ( | $fname | ) |
Set the method name to be included in an SQL comment.
| string | $fname |
Implements Wikimedia\Rdbms\IWriteQueryBuilder.
Definition at line 290 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\caller().
Referenced by Wikimedia\Rdbms\UpdateQueryBuilder\caller(), and Wikimedia\Rdbms\UpdateQueryBuilder\queryInfo().
| Wikimedia\Rdbms\UpdateQueryBuilder::conds | ( | $conds | ) |
Add conditions to the query.
Alias for where().
| string|IExpression|array<string,?scalar|non-empty-array<int,?scalar>|RawSQLValue>|array<int,string|IExpression> | $conds |
Definition at line 222 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\where().
Referenced by Wikimedia\Rdbms\UpdateQueryBuilder\where().
| Wikimedia\Rdbms\UpdateQueryBuilder::connection | ( | IDatabase | $db | ) |
Change the IDatabase object the query builder is bound to.The specified IDatabase will subsequently be used to execute the query.
| IDatabase | $db |
Implements Wikimedia\Rdbms\IWriteQueryBuilder.
Definition at line 60 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\$db, and Wikimedia\Rdbms\IReadableDatabase\getType().
| Wikimedia\Rdbms\UpdateQueryBuilder::execute | ( | ) |
Run the constructed query.
Implements Wikimedia\Rdbms\IWriteQueryBuilder.
Definition at line 298 of file UpdateQueryBuilder.php.
| Wikimedia\Rdbms\UpdateQueryBuilder::getQueryInfo | ( | ) |
Get an associative array describing the query in terms of its raw parameters to the counter-part method in Database object.This can be used to interface with legacy code.
Implements Wikimedia\Rdbms\IWriteQueryBuilder.
Definition at line 317 of file UpdateQueryBuilder.php.
| Wikimedia\Rdbms\UpdateQueryBuilder::ignore | ( | ) |
Enable the IGNORE option.
Skip update of rows that would cause unique key conflicts. IDatabase::affectedRows() can be used to determine how many rows were updated.
Definition at line 282 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\options().
| Wikimedia\Rdbms\UpdateQueryBuilder::option | ( | $name, | |
| $value = null ) |
Manually set an option in the $options array to be passed to IDatabase::update()
| string | $name | The option name |
| mixed | $value | The option value, or null for a boolean option |
Definition at line 123 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\options().
| Wikimedia\Rdbms\UpdateQueryBuilder::options | ( | array | $options | ) |
Manually set multiple options in the $options array to be passed to IDatabase::update().
| array | $options |
Definition at line 139 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\options().
Referenced by Wikimedia\Rdbms\UpdateQueryBuilder\ignore(), Wikimedia\Rdbms\UpdateQueryBuilder\option(), Wikimedia\Rdbms\UpdateQueryBuilder\options(), and Wikimedia\Rdbms\UpdateQueryBuilder\queryInfo().
| Wikimedia\Rdbms\UpdateQueryBuilder::queryInfo | ( | $info | ) |
Set the query parameters to the given values, appending to the values which were already set.This can be used to interface with legacy code. If a key is omitted, the previous value will be retained.The parameters must be formatted as required by the counter-part method in Database object.
| array | $info | Associative array of query info, with keys:
|
Implements Wikimedia\Rdbms\IWriteQueryBuilder.
Definition at line 73 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\caller(), Wikimedia\Rdbms\UpdateQueryBuilder\options(), Wikimedia\Rdbms\UpdateQueryBuilder\table(), and Wikimedia\Rdbms\UpdateQueryBuilder\where().
| Wikimedia\Rdbms\UpdateQueryBuilder::set | ( | $set | ) |
Add SET part to the query.
It takes an array containing arrays of column names map to the set values.
| string|array<string,?scalar|RawSQLValue>|array<int,string> | $set |
Combination map/list where each string-keyed entry maps a column to a literal assigned value and each integer-keyed value is a SQL expression in the format of a column assignment within UPDATE...SET. The (column => value) entries are convenient due to automatic value quoting and conversion of null to NULL. The SQL assignment format is useful for updates like "column = column + X". All assignments have no defined execution order, so they should not depend on each other. Do not modify AUTOINCREMENT or UUID columns in assignments.
Untrusted user input is safe in the values of string keys, however untrusted input must not be used in the array key names or in the values of numeric keys. Escaping of untrusted input used in values of numeric keys should be done via IDatabase::addQuotes()
Definition at line 248 of file UpdateQueryBuilder.php.
| Wikimedia\Rdbms\UpdateQueryBuilder::table | ( | $table | ) |
Manually set the table name to be passed to IDatabase::update()
| string | $table | The unqualified name of a table |
Definition at line 99 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\table().
Referenced by Wikimedia\Rdbms\UpdateQueryBuilder\queryInfo(), Wikimedia\Rdbms\UpdateQueryBuilder\table(), and Wikimedia\Rdbms\UpdateQueryBuilder\update().
| Wikimedia\Rdbms\UpdateQueryBuilder::update | ( | string | $table | ) |
Set table for the query.
Alias for table().
| string | $table | The unqualified name of a table |
Definition at line 111 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\table().
| Wikimedia\Rdbms\UpdateQueryBuilder::where | ( | $conds | ) |
Add conditions to the query.
The supplied conditions will be appended to the existing conditions, separated by AND.
| string|IExpression|array<string,?scalar|non-empty-array<int,?scalar>|RawSQLValue>|array<int,string|IExpression> | $conds |
May be either a string containing a single condition, or an array of conditions. If an array is given, the conditions constructed from each element are combined with AND.
Array elements may take one of two forms:
Note that expressions are often DBMS-dependent in their syntax. DBMS-independent wrappers are provided for constructing several types of expression commonly used in condition queries. See:
Untrusted user input is safe in the values of string keys, however untrusted input must not be used in the array key names or in the values of numeric keys. Escaping of untrusted input used in values of numeric keys should be done via IDatabase::addQuotes().
Definition at line 182 of file UpdateQueryBuilder.php.
References Wikimedia\Rdbms\UpdateQueryBuilder\conds(), and Wikimedia\Rdbms\Platform\ISQLPlatform\LIST_AND.
Referenced by Wikimedia\Rdbms\UpdateQueryBuilder\andWhere(), Wikimedia\Rdbms\UpdateQueryBuilder\conds(), and Wikimedia\Rdbms\UpdateQueryBuilder\queryInfo().
|
protected |
Definition at line 47 of file UpdateQueryBuilder.php.
Referenced by Wikimedia\Rdbms\UpdateQueryBuilder\__construct(), and Wikimedia\Rdbms\UpdateQueryBuilder\connection().
|
protected |
The options to be passed to IDatabase::update()
Definition at line 45 of file UpdateQueryBuilder.php.