MediaWiki  master
Wikimedia\Rdbms\SelectQueryBuilder Class Reference
Inheritance diagram for Wikimedia\Rdbms\SelectQueryBuilder:
Collaboration diagram for Wikimedia\Rdbms\SelectQueryBuilder:

Public Member Functions

 __construct (IDatabase $db)
 
 andWhere ( $conds)
 Add conditions to the query. More...
 
 bigResult ()
 Enable the SQL_BIG_RESULT option. More...
 
 bufferResult ()
 Enable the SQL_BUFFER_RESULT option. More...
 
 buildGroupConcatField ( $delim)
 Build a GROUP_CONCAT or equivalent statement for a query. More...
 
 calcFoundRows ()
 Enable the SQL_CALC_FOUND_ROWS option. More...
 
 caller ( $fname)
 Set the method name to be included in an SQL comment. More...
 
 conds ( $conds)
 Add conditions to the query. More...
 
 connection (IDatabase $db)
 Change the IDatabase object the query builder is bound to. More...
 
 distinct ()
 Enable the DISTINCT option. More...
 
 estimateRowCount ()
 Estimate the number of rows in dataset. More...
 
 explain ()
 Make the query be an EXPLAIN SELECT query instead of a SELECT query. More...
 
 fetchField ()
 Run the constructed SELECT query, and return a single field extracted from the first result row. More...
 
 fetchFieldValues ()
 Run the constructed SELECT query, and extract a single field from each result row, returning an array containing all the values. More...
 
 fetchResultSet ()
 Run the constructed SELECT query and return all results. More...
 
 fetchRow ()
 Run the constructed SELECT query, and return the first result row. More...
 
 fetchRowCount ()
 Run the SELECT query, and return the number of results. More...
 
 field ( $field, $alias=null)
 Add a single field to the query, optionally with an alias. More...
 
 fields ( $fields)
 Add a field or an array of fields to the query. More...
 
 forUpdate ()
 Enable the FOR UPDATE option. More...
 
 from ( $table, $alias=null)
 Add a single table to the SELECT query. More...
 
 getQueryInfo ()
 Get an associative array describing the query in terms of its raw parameters to Database::select(). More...
 
 getSQL ()
 Get the SQL query string which would be used by fetchResultSet(). More...
 
 groupBy ( $group)
 Add a GROUP BY clause. More...
 
 having ( $having)
 Add a HAVING clause. More...
 
 ignoreIndex ( $index)
 Set the IGNORE INDEX option. More...
 
 joinConds (array $joinConds)
 Manually append to the $join_conds array which will be passed to IDatabase::select(). More...
 
 limit ( $limit)
 Set the query limit. More...
 
 lockForUpdate ()
 Run the SELECT query with the FOR UPDATE option. More...
 
 lockInShareMode ()
 Enable the LOCK IN SHARE MODE option. More...
 
 newJoinGroup ()
 Create a parenthesized group of joins which can be added to the object like a table. More...
 
 newSubquery ()
 Get an empty SelectQueryBuilder which can be used to build a subquery of this query. More...
 
 offset ( $offset)
 Set the offset. More...
 
 option ( $name, $value=null)
 Manually set an option in the $options array to be passed to IDatabase::select() More...
 
 options (array $options)
 Manually set multiple options in the $options array to be passed to IDatabase::select(). More...
 
 orderBy ( $fields, $direction=null)
 Set the ORDER BY clause. More...
 
 queryInfo ( $info)
 Set the query parameters to the given values, appending to the values which were already set. More...
 
 rawTables ( $tables)
 Given a table or table array as might be passed to Database::select(), append it to the existing tables, interpreting nested arrays as join groups. More...
 
 select ( $fields)
 Add a field or an array of fields to the query. More...
 
 smallResult ()
 Enable the SQL_SMALL_RESULT option. More...
 
 straightJoin ()
 Enable the STRAIGHT_JOIN option. More...
 
 tables ( $tables)
 Add multiple tables. More...
 
 useIndex ( $index)
 Set a USE INDEX option. More...
 
 where ( $conds)
 Add conditions to the query. More...
 
- Public Member Functions inherited from Wikimedia\Rdbms\JoinGroupBase
 join ( $table, $alias=null, $conds=[])
 Inner join a table or group of tables. More...
 
 leftJoin ( $table, $alias=null, $conds=[])
 Left join a table or group of tables. More...
 
 table ( $table, $alias=null)
 Add a single table or a single parenthesized group. More...
 

Protected Member Functions

 getAutoAlias ()
 Get a table alias which is unique to this SelectQueryBuilder. More...
 

Private Member Functions

 getRowCountVar ()
 Private helper which extracts a field suitable for row counting from the fields array. More...
 
 mergeOption ( $name, $newArrayOrValue)
 Add a value to an option which may be not set or a string or array. More...
 
 setIndexHint ( $type, $value)
 Private helper for methods that set index hints. More...
 

Private Attributes

string $caller = __CLASS__
 The caller (function name) to be passed to IDatabase::select() More...
 
array $conds = []
 The conditions to be passed to IDatabase::select() More...
 
IDatabase $db
 
array $fields = []
 The fields to be passed to IDatabase::select() More...
 
int $nextAutoAlias = 1
 An integer used to assign automatic aliases to tables and groups. More...
 
array $options = []
 The options to be passed to IDatabase::select() More...
 

Additional Inherited Members

- Protected Attributes inherited from Wikimedia\Rdbms\JoinGroupBase
array $joinConds = []
 
 $lastAlias
 
array $tables = []
 

Detailed Description

Definition at line 5 of file SelectQueryBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 39 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\$db.

Member Function Documentation

◆ andWhere()

Wikimedia\Rdbms\SelectQueryBuilder::andWhere (   $conds)

Add conditions to the query.

Alias for where().

Parameters
string | array$conds
Returns
$this

Definition at line 253 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\where().

◆ bigResult()

Wikimedia\Rdbms\SelectQueryBuilder::bigResult ( )

Enable the SQL_BIG_RESULT option.

Returns
$this

Definition at line 519 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ bufferResult()

Wikimedia\Rdbms\SelectQueryBuilder::bufferResult ( )

Enable the SQL_BUFFER_RESULT option.

Returns
$this

Definition at line 529 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ buildGroupConcatField()

Wikimedia\Rdbms\SelectQueryBuilder::buildGroupConcatField (   $delim)

Build a GROUP_CONCAT or equivalent statement for a query.

This is useful for combining a field for several rows into a single string. NULL values will not appear in the output, duplicated values will appear, and the resulting delimiter-separated values have no defined sort order. Code using the results may need to use the PHP unique() or sort() methods.

Parameters
string$delim
Returns
string

Definition at line 714 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\conds(), Wikimedia\Rdbms\SelectQueryBuilder\fields(), Wikimedia\Rdbms\SelectQueryBuilder\joinConds(), and Wikimedia\Rdbms\SelectQueryBuilder\tables().

◆ calcFoundRows()

Wikimedia\Rdbms\SelectQueryBuilder::calcFoundRows ( )

Enable the SQL_CALC_FOUND_ROWS option.

Returns
$this

Definition at line 549 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ caller()

◆ conds()

◆ connection()

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

Definition at line 50 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\$db, and Wikimedia\Rdbms\IDatabase\getType().

◆ distinct()

Wikimedia\Rdbms\SelectQueryBuilder::distinct ( )

Enable the DISTINCT option.

Return only unique result rows.

Returns
$this

Definition at line 358 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ estimateRowCount()

Wikimedia\Rdbms\SelectQueryBuilder::estimateRowCount ( )

Estimate the number of rows in dataset.

MySQL allows you to estimate the number of rows that would be returned by a SELECT query, using EXPLAIN SELECT. The estimate is provided using index cardinality statistics, and is notoriously inaccurate, especially when large numbers of rows have recently been added or deleted.

Returns
int

Definition at line 671 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\caller(), Wikimedia\Rdbms\SelectQueryBuilder\conds(), Wikimedia\Rdbms\SelectQueryBuilder\getRowCountVar(), Wikimedia\Rdbms\SelectQueryBuilder\joinConds(), Wikimedia\Rdbms\SelectQueryBuilder\options(), and Wikimedia\Rdbms\SelectQueryBuilder\tables().

◆ explain()

Wikimedia\Rdbms\SelectQueryBuilder::explain ( )

Make the query be an EXPLAIN SELECT query instead of a SELECT query.

Returns
$this

Definition at line 499 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ fetchField()

Wikimedia\Rdbms\SelectQueryBuilder::fetchField ( )

Run the constructed SELECT query, and return a single field extracted from the first result row.

This may only be called when only one field has been added to the builder.

Returns
mixed

Definition at line 611 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\caller(), Wikimedia\Rdbms\SelectQueryBuilder\conds(), Wikimedia\Rdbms\SelectQueryBuilder\fields(), Wikimedia\Rdbms\SelectQueryBuilder\joinConds(), Wikimedia\Rdbms\SelectQueryBuilder\options(), and Wikimedia\Rdbms\SelectQueryBuilder\tables().

◆ fetchFieldValues()

Wikimedia\Rdbms\SelectQueryBuilder::fetchFieldValues ( )

Run the constructed SELECT query, and extract a single field from each result row, returning an array containing all the values.

This may only be called when only one field has been added to the builder.

Returns
array

Definition at line 628 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\caller(), Wikimedia\Rdbms\SelectQueryBuilder\conds(), Wikimedia\Rdbms\SelectQueryBuilder\fields(), Wikimedia\Rdbms\SelectQueryBuilder\joinConds(), Wikimedia\Rdbms\SelectQueryBuilder\options(), and Wikimedia\Rdbms\SelectQueryBuilder\tables().

◆ fetchResultSet()

◆ fetchRow()

Wikimedia\Rdbms\SelectQueryBuilder::fetchRow ( )

◆ fetchRowCount()

Wikimedia\Rdbms\SelectQueryBuilder::fetchRowCount ( )

Run the SELECT query, and return the number of results.

This typically uses a subquery to discard the actual results on the server side, and is useful when counting rows with a limit.

Returns
int

Definition at line 656 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\caller(), Wikimedia\Rdbms\SelectQueryBuilder\conds(), Wikimedia\Rdbms\SelectQueryBuilder\getRowCountVar(), Wikimedia\Rdbms\SelectQueryBuilder\joinConds(), Wikimedia\Rdbms\SelectQueryBuilder\options(), and Wikimedia\Rdbms\SelectQueryBuilder\tables().

◆ field()

Wikimedia\Rdbms\SelectQueryBuilder::field (   $field,
  $alias = null 
)

Add a single field to the query, optionally with an alias.

The field is an SQL fragment. It is unsafe to pass user input to this function.

Parameters
string$field
string | null$alias
Returns
$this

Definition at line 193 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\fields().

◆ fields()

◆ forUpdate()

Wikimedia\Rdbms\SelectQueryBuilder::forUpdate ( )

Enable the FOR UPDATE option.

Lock the returned rows so that they can't be changed until the next COMMIT. Cannot be used with aggregate functions (COUNT, MAX, etc., but also DISTINCT).

Returns
$this

Definition at line 348 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ from()

Wikimedia\Rdbms\SelectQueryBuilder::from (   $table,
  $alias = null 
)

Add a single table to the SELECT query.

Alias for table().

Parameters
string$tableThe table name
string | null$aliasThe table alias, or null for no alias
Returns
$this

Definition at line 135 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\JoinGroupBase\table().

◆ getAutoAlias()

Wikimedia\Rdbms\SelectQueryBuilder::getAutoAlias ( )
protected

Get a table alias which is unique to this SelectQueryBuilder.

Returns
string

Reimplemented from Wikimedia\Rdbms\JoinGroupBase.

Definition at line 285 of file SelectQueryBuilder.php.

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\newJoinGroup().

◆ getQueryInfo()

Wikimedia\Rdbms\SelectQueryBuilder::getQueryInfo ( )

Get an associative array describing the query in terms of its raw parameters to Database::select().

This can be used to interface with legacy code.

Returns
array The query info array, with keys:
  • tables: The table array
  • fields: The fields
  • conds: The conditions
  • options: The query options
  • join_conds: The join conditions

Definition at line 745 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\$conds, Wikimedia\Rdbms\SelectQueryBuilder\$fields, Wikimedia\Rdbms\JoinGroupBase\$joinConds, Wikimedia\Rdbms\SelectQueryBuilder\$options, and Wikimedia\Rdbms\JoinGroupBase\$tables.

Referenced by ApiQueryBase\select().

◆ getRowCountVar()

Wikimedia\Rdbms\SelectQueryBuilder::getRowCountVar ( )
private

Private helper which extracts a field suitable for row counting from the fields array.

Returns
string

Definition at line 682 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\fields().

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\estimateRowCount(), and Wikimedia\Rdbms\SelectQueryBuilder\fetchRowCount().

◆ getSQL()

◆ groupBy()

Wikimedia\Rdbms\SelectQueryBuilder::groupBy (   $group)

Add a GROUP BY clause.

May be either an SQL fragment string naming a field or expression to group by, or an array of such SQL fragments.

If there is an existing GROUP BY clause, the new one will be appended.

Parameters
string | string[]$group
Returns
$this

Definition at line 372 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\mergeOption().

◆ having()

Wikimedia\Rdbms\SelectQueryBuilder::having (   $having)

Add a HAVING clause.

May be either an string containing a HAVING clause or an array of conditions building the HAVING clause. If an array is given, the conditions constructed from each element are combined with AND.

If there is an existing HAVING clause, the new one will be appended.

Parameters
string | string[]$having
Returns
$this

Definition at line 388 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\mergeOption().

◆ ignoreIndex()

Wikimedia\Rdbms\SelectQueryBuilder::ignoreIndex (   $index)

Set the IGNORE INDEX option.

If a string is given, the index hint is applied to the most recently appended table or alias. If an array is given, it is assumed to be an associative array with the alias names in the keys and the indexes in the values, as in the IGNORE INDEX option to IDatabase::select(). The array will be merged with the existing value.

Parameters
string | string[]$index
Returns
$this

Definition at line 463 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\setIndexHint().

◆ joinConds()

◆ limit()

Wikimedia\Rdbms\SelectQueryBuilder::limit (   $limit)

Set the query limit.

Return at most this many rows. The rows are sorted and then the first rows are taken until the limit is reached. Limit is applied to a result set after offset.

If the query builder already has a limit, the old limit will be discarded.

Parameters
int$limit
Returns
$this

Definition at line 324 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ lockForUpdate()

Wikimedia\Rdbms\SelectQueryBuilder::lockForUpdate ( )

◆ lockInShareMode()

Wikimedia\Rdbms\SelectQueryBuilder::lockInShareMode ( )

Enable the LOCK IN SHARE MODE option.

Lock the returned rows so that they can't be changed until the next COMMIT. Cannot be used with aggregate functions (COUNT, MAX, etc., but also DISTINCT).

Returns
$this

Definition at line 336 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ mergeOption()

Wikimedia\Rdbms\SelectQueryBuilder::mergeOption (   $name,
  $newArrayOrValue 
)
private

Add a value to an option which may be not set or a string or array.

Parameters
string$name
string | string[]$newArrayOrValue

Definition at line 423 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\groupBy(), Wikimedia\Rdbms\SelectQueryBuilder\having(), and Wikimedia\Rdbms\SelectQueryBuilder\orderBy().

◆ newJoinGroup()

Wikimedia\Rdbms\SelectQueryBuilder::newJoinGroup ( )

Create a parenthesized group of joins which can be added to the object like a table.

The group is initially empty.

Returns
JoinGroup

Definition at line 295 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\getAutoAlias().

◆ newSubquery()

Wikimedia\Rdbms\SelectQueryBuilder::newSubquery ( )

Get an empty SelectQueryBuilder which can be used to build a subquery of this query.

Returns
SelectQueryBuilder

Definition at line 124 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\$db.

◆ offset()

Wikimedia\Rdbms\SelectQueryBuilder::offset (   $offset)

Set the offset.

Skip this many rows at the start of the result set. Offset with limit() can theoretically be used for paging through a result set, but this is discouraged for performance reasons.

If the query builder already has an offset, the old offset will be discarded.

Parameters
int$offset
Returns
$this

Definition at line 309 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ option()

Wikimedia\Rdbms\SelectQueryBuilder::option (   $name,
  $value = null 
)

Manually set an option in the $options array to be passed to IDatabase::select()

Parameters
string$nameThe option name
mixed$valueThe option value, or null for a boolean option
Returns
$this

Definition at line 562 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ options()

◆ orderBy()

Wikimedia\Rdbms\SelectQueryBuilder::orderBy (   $fields,
  $direction = null 
)

Set the ORDER BY clause.

If it has already been set, append the additional fields to it.

Parameters
string[] | string$fieldsThe field or list of fields to order by.
string | null$directionASC or DESC. If this is null then $fields is assumed to optionally contain ASC or DESC after each field name.
Returns
$this

Definition at line 402 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\$fields, and Wikimedia\Rdbms\SelectQueryBuilder\mergeOption().

◆ queryInfo()

Wikimedia\Rdbms\SelectQueryBuilder::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 Database::select. For example, JoinGroup cannot be used.

Parameters
array$infoAssociative array of query info, with keys:
  • tables: The raw array of tables to be passed to Database::select()
  • fields: The fields
  • conds: The conditions
  • options: The query options
  • join_conds: The join conditions
Returns
$this

Definition at line 76 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\fields(), Wikimedia\Rdbms\SelectQueryBuilder\joinConds(), Wikimedia\Rdbms\SelectQueryBuilder\options(), Wikimedia\Rdbms\SelectQueryBuilder\rawTables(), and Wikimedia\Rdbms\SelectQueryBuilder\where().

◆ rawTables()

Wikimedia\Rdbms\SelectQueryBuilder::rawTables (   $tables)

Given a table or table array as might be passed to Database::select(), append it to the existing tables, interpreting nested arrays as join groups.

This can be used to interface with existing code that expresses join groups as nested arrays. In new code, join groups should generally be created with newJoinGroup(), which provides a fluent interface.

Parameters
string | array$tables
Returns
$this

Definition at line 107 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\JoinGroupBase\$tables, and Wikimedia\Rdbms\SelectQueryBuilder\tables().

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\queryInfo(), and ApiQueryBase\select().

◆ select()

Wikimedia\Rdbms\SelectQueryBuilder::select (   $fields)

Add a field or an array of fields to the query.

Alias for fields().

Parameters
string | string[]$fields
Returns
$this

Definition at line 181 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\fields().

◆ setIndexHint()

Wikimedia\Rdbms\SelectQueryBuilder::setIndexHint (   $type,
  $value 
)
private

Private helper for methods that set index hints.

Parameters
string$type
string | string[]$value

Definition at line 474 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\JoinGroupBase\$lastAlias, $type, and Wikimedia\Rdbms\SelectQueryBuilder\options().

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\ignoreIndex(), and Wikimedia\Rdbms\SelectQueryBuilder\useIndex().

◆ smallResult()

Wikimedia\Rdbms\SelectQueryBuilder::smallResult ( )

Enable the SQL_SMALL_RESULT option.

Returns
$this

Definition at line 539 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ straightJoin()

Wikimedia\Rdbms\SelectQueryBuilder::straightJoin ( )

Enable the STRAIGHT_JOIN option.

Returns
$this

Definition at line 509 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\options().

◆ tables()

◆ useIndex()

Wikimedia\Rdbms\SelectQueryBuilder::useIndex (   $index)

Set a USE INDEX option.

If a string is given, the index hint is applied to the most recently appended table or alias. If an array is given, it is assumed to be an associative array with the alias names in the keys and the indexes in the values, as in the USE INDEX option to IDatabase::select(). The array will be merged with the existing value.

Parameters
string | string[]$index
Returns
$this

Definition at line 446 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\setIndexHint().

◆ where()

Wikimedia\Rdbms\SelectQueryBuilder::where (   $conds)

Add conditions to the query.

The supplied conditions will be appended to the existing conditions, separated by AND.

Parameters
string | array$condsMay 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:

  • Elements with a numeric key are interpreted as raw SQL fragments.
  • Elements with a string key are interpreted as equality conditions, where the key is the field name.
    • If the value of such an array element is a scalar (such as a string), it will be treated as data and thus quoted appropriately. If it is null, an IS NULL clause will be added.
    • If the value is an array, an IN (...) clause will be constructed from its non-null elements, and an IS NULL clause will be added if null is present, such that the field may match any of the elements in the array. The non-null elements will be quoted.

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()

Returns
$this

Definition at line 238 of file SelectQueryBuilder.php.

References Wikimedia\Rdbms\SelectQueryBuilder\$conds, and Wikimedia\Rdbms\SelectQueryBuilder\conds().

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\andWhere(), Wikimedia\Rdbms\SelectQueryBuilder\conds(), Wikimedia\Rdbms\SelectQueryBuilder\queryInfo(), and ApiQueryBase\select().

Member Data Documentation

◆ $caller

string Wikimedia\Rdbms\SelectQueryBuilder::$caller = __CLASS__
private

The caller (function name) to be passed to IDatabase::select()

Definition at line 19 of file SelectQueryBuilder.php.

◆ $conds

array Wikimedia\Rdbms\SelectQueryBuilder::$conds = []
private

◆ $db

◆ $fields

array Wikimedia\Rdbms\SelectQueryBuilder::$fields = []
private

◆ $nextAutoAlias

int Wikimedia\Rdbms\SelectQueryBuilder::$nextAutoAlias = 1
private

An integer used to assign automatic aliases to tables and groups.

Definition at line 29 of file SelectQueryBuilder.php.

◆ $options

array Wikimedia\Rdbms\SelectQueryBuilder::$options = []
private

The options to be passed to IDatabase::select()

Definition at line 24 of file SelectQueryBuilder.php.

Referenced by Wikimedia\Rdbms\SelectQueryBuilder\getQueryInfo().


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