MediaWiki master
Wikimedia\Rdbms\ReplaceQueryBuilder Class Reference

Build REPLACE queries with a fluent interface. More...

Inherits Wikimedia\Rdbms\IWriteQueryBuilder.

Collaboration diagram for Wikimedia\Rdbms\ReplaceQueryBuilder:

Public Member Functions

 __construct (IDatabase $db)
 Only for use in subclasses.
 
 caller ( $fname)
 Set the method name to be included in an SQL comment.
Parameters
string$fname
Returns
$this

 
 connection (IDatabase $db)
 Change the IDatabase object the query builder is bound to.The specified IDatabase will subsequently be used to execute the query.
Parameters
IDatabase$db
Returns
$this

 
 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.
Returns
array The query info array, with keys:
  • table: The table name
  • set: The set array
  • conds: The conditions
  • options: The query options
  • caller: The caller signature

 
 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.
Parameters
array$infoAssociative array of query info, with keys:
  • table: The table name to be passed to the counter-part method in Database object
  • set: The set conditions
  • conds: The conditions
  • options: The query options
  • caller: The caller signature.
Returns
$this

 
 replaceInto (string $table)
 Set table for the query.
 
 row (array $row)
 Add one row to be inserted.
 
 rows (array $rows)
 Add rows to be inserted.
 
 table ( $table)
 Manually set the table name to be passed to IDatabase::replace()
 
 uniqueIndexFields ( $uniqueIndexFields)
 Set the unique index fields.
 

Protected Attributes

IDatabase $db
 

Detailed Description

Build REPLACE 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.

Since
1.41
Stability: stable
to extend

Definition at line 21 of file ReplaceQueryBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\ReplaceQueryBuilder::__construct ( IDatabase $db)

Only for use in subclasses.

To create a ReplaceQueryBuilder instance, use $db->newReplaceQueryBuilder() instead.

Definition at line 48 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\$db.

Member Function Documentation

◆ caller()

Wikimedia\Rdbms\ReplaceQueryBuilder::caller ( $fname)

Set the method name to be included in an SQL comment.

Parameters
string$fname
Returns
$this

Implements Wikimedia\Rdbms\IWriteQueryBuilder.

Definition at line 153 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\caller().

Referenced by Wikimedia\Rdbms\ReplaceQueryBuilder\caller(), and Wikimedia\Rdbms\ReplaceQueryBuilder\queryInfo().

◆ connection()

Wikimedia\Rdbms\ReplaceQueryBuilder::connection ( IDatabase $db)

Change the IDatabase object the query builder is bound to.The specified IDatabase will subsequently be used to execute the query.

Parameters
IDatabase$db
Returns
$this

Implements Wikimedia\Rdbms\IWriteQueryBuilder.

Definition at line 55 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\$db, and Wikimedia\Rdbms\IReadableDatabase\getType().

◆ execute()

Wikimedia\Rdbms\ReplaceQueryBuilder::execute ( )

Run the constructed query.

Implements Wikimedia\Rdbms\IWriteQueryBuilder.

Definition at line 161 of file ReplaceQueryBuilder.php.

◆ getQueryInfo()

Wikimedia\Rdbms\ReplaceQueryBuilder::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.

Returns
array The query info array, with keys:
  • table: The table name
  • set: The set array
  • conds: The conditions
  • options: The query options
  • caller: The caller signature

Implements Wikimedia\Rdbms\IWriteQueryBuilder.

Definition at line 180 of file ReplaceQueryBuilder.php.

◆ queryInfo()

Wikimedia\Rdbms\ReplaceQueryBuilder::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.

Parameters
array$infoAssociative array of query info, with keys:
  • table: The table name to be passed to the counter-part method in Database object
  • set: The set conditions
  • conds: The conditions
  • options: The query options
  • caller: The caller signature.
Returns
$this

Implements Wikimedia\Rdbms\IWriteQueryBuilder.

Definition at line 68 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\caller(), Wikimedia\Rdbms\ReplaceQueryBuilder\rows(), Wikimedia\Rdbms\ReplaceQueryBuilder\table(), and Wikimedia\Rdbms\ReplaceQueryBuilder\uniqueIndexFields().

◆ replaceInto()

Wikimedia\Rdbms\ReplaceQueryBuilder::replaceInto ( string $table)

Set table for the query.

Alias for table().

Parameters
string$tableThe unqualified name of a table
Returns
$this

Definition at line 103 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\table().

◆ row()

Wikimedia\Rdbms\ReplaceQueryBuilder::row ( array $row)

Add one row to be inserted.

Parameters
array$row$row must be a string-keyed map of (column name => value) defining a new row. Values are treated as literals and quoted appropriately; null is interpreted as NULL.
Returns
$this

Definition at line 131 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\rows().

◆ rows()

Wikimedia\Rdbms\ReplaceQueryBuilder::rows ( array $rows)

Add rows to be inserted.

Parameters
list<array>$rows $rows should be an integer-keyed list of such string-keyed maps, defining a list of new rows. The keys in each map must be identical to each other and in the same order. The rows must not collide with each other.
Returns
$this

Definition at line 117 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\rows().

Referenced by Wikimedia\Rdbms\ReplaceQueryBuilder\queryInfo(), Wikimedia\Rdbms\ReplaceQueryBuilder\row(), and Wikimedia\Rdbms\ReplaceQueryBuilder\rows().

◆ table()

Wikimedia\Rdbms\ReplaceQueryBuilder::table ( $table)

Manually set the table name to be passed to IDatabase::replace()

Parameters
string$tableThe unqualified name of a table
Returns
$this

Definition at line 91 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\table().

Referenced by Wikimedia\Rdbms\ReplaceQueryBuilder\queryInfo(), Wikimedia\Rdbms\ReplaceQueryBuilder\replaceInto(), and Wikimedia\Rdbms\ReplaceQueryBuilder\table().

◆ uniqueIndexFields()

Wikimedia\Rdbms\ReplaceQueryBuilder::uniqueIndexFields ( $uniqueIndexFields)

Set the unique index fields.

Parameters
string | string[]$uniqueIndexFields
Returns
$this

Definition at line 142 of file ReplaceQueryBuilder.php.

References Wikimedia\Rdbms\ReplaceQueryBuilder\uniqueIndexFields().

Referenced by Wikimedia\Rdbms\ReplaceQueryBuilder\queryInfo(), and Wikimedia\Rdbms\ReplaceQueryBuilder\uniqueIndexFields().

Member Data Documentation

◆ $db

IDatabase Wikimedia\Rdbms\ReplaceQueryBuilder::$db
protected

The documentation for this class was generated from the following file: