MediaWiki master
ISQLPlatform.php
Go to the documentation of this file.
1<?php
21
27
28// Very long type annotations :(
29// phpcs:disable Generic.Files.LineLength
30
38interface ISQLPlatform {
39
41 public const LIST_COMMA = 0;
43 public const LIST_AND = 1;
45 public const LIST_SET = 2;
47 public const LIST_NAMES = 3;
49 public const LIST_OR = 4;
50
52 public const ALL_ROWS = '*';
53
55 public const QUERY_NORMAL = 0;
57 public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
59 public const QUERY_PSEUDO_PERMANENT = 2;
61 public const QUERY_REPLICA_ROLE = 4;
63 public const QUERY_IGNORE_DBO_TRX = 8;
65 public const QUERY_NO_RETRY = 16;
67 public const QUERY_CHANGE_NONE = 32;
69 public const QUERY_CHANGE_TRX = 64;
71 public const QUERY_CHANGE_ROWS = 128;
73 public const QUERY_CHANGE_SCHEMA = 256;
75 public const QUERY_CHANGE_LOCKS = 512;
76
82 public const CALLER_SUBQUERY = 'subquery';
83
88 public const CALLER_UNKNOWN = 'unknown';
89
94 public function bitNot( $field );
95
101 public function bitAnd( $fieldLeft, $fieldRight );
102
108 public function bitOr( $fieldLeft, $fieldRight );
109
121 public function addIdentifierQuotes( $s );
122
137 public function buildGreatest( $fields, $values );
138
153 public function buildLeast( $fields, $values );
154
183 public function buildComparison( string $op, array $conds ): string;
184
213 public function makeList( array $a, $mode = self::LIST_COMMA );
214
245 public function makeWhereFrom2d( $data, $baseKey, $subKey );
246
276 public function factorConds( $condsArray );
277
283 public function buildConcat( $stringList );
284
302 public function limitResult( $sql, $limit, $offset = false );
303
326 public function buildLike( $param, ...$params );
327
333 public function anyChar();
334
340 public function anyString();
341
347 public function unionSupportsOrderAndLimit();
348
363 public function unionQueries( $sqls, $all, $options = [] );
364
376 public function timestamp( $ts = 0 );
377
392 public function timestampOrNull( $ts = null );
393
401 public function getInfinity();
402
409 public function encodeExpiry( $expiry );
410
418 public function decodeExpiry( $expiry, $format = TS_MW );
419
431 public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
432
441 public function strreplace( $orig, $old, $new );
442
455 public function buildSubString( $input, $startPosition, $length = null );
456
462 public function buildStringCast( $field );
463
469 public function buildIntegerCast( $field );
470
477 public function implicitOrderby();
478
492 public function setTableAliases( array $aliases );
493
506 public function setIndexAliases( array $aliases );
507
513 public function getTableAliases();
514
541 public function selectSQLText(
542 $tables,
543 $vars,
544 $conds = '',
545 $fname = __METHOD__,
546 $options = [],
547 $join_conds = []
548 );
549
576 public function tableName( string $name, $format = 'quoted' );
577
599 public function tableNames( ...$tables );
600
621 public function tableNamesN( ...$tables );
622
641 public function buildGroupConcatField(
642 $delim, $tables, $field, $conds = '', $join_conds = []
643 );
644
660 public function buildSelectSubquery(
661 $tables,
662 $vars,
663 $conds = '',
664 $fname = __METHOD__,
665 $options = [],
666 $join_conds = []
667 );
668
686 public function buildExcludedValue( $column );
687
695 public function setSchemaVars( $vars );
696}
array $params
The job parameters.
Database error base class.
Definition DBError.php:36
Used by Database::buildLike() to represent characters that have special meaning in SQL LIKE clauses a...
Definition LikeMatch.php:10
Raw SQL value to be used in query builders.
Interface for query language.
unionQueries( $sqls, $all, $options=[])
Construct a UNION query.
const CALLER_UNKNOWN
Special value for ->caller() / $fname parameter used when a caller is not provided.
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
bitOr( $fieldLeft, $fieldRight)
const LIST_SET
Convert map into a SET clause.
tableNamesN(... $tables)
Fetch a number of table names into a zero-indexed numerical array.
strreplace( $orig, $old, $new)
Returns a SQL expression for simple string replacement (e.g.
limitResult( $sql, $limit, $offset=false)
Construct a LIMIT query with optional offset.
const QUERY_CHANGE_ROWS
Query is a Data Manipulation Language command (INSERT, DELETE, LOCK, ...)
const QUERY_NO_RETRY
Do not try to retry the query if the connection was lost.
const CALLER_SUBQUERY
Special value for ->caller() / $fname parameter used when providing a caller is not expected,...
makeList(array $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
tableName(string $name, $format='quoted')
Format a table name ready for use in constructing an SQL query.
buildExcludedValue( $column)
Build a reference to a column value from the conflicting proposed upsert() row.
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
buildGreatest( $fields, $values)
Build a GREATEST function statement comparing columns/values.
bitAnd( $fieldLeft, $fieldRight)
const QUERY_NORMAL
Idiom for "no special flags".
buildLeast( $fields, $values)
Build a LEAST function statement comparing columns/values.
conditional( $cond, $caseTrueExpression, $caseFalseExpression)
Returns an SQL expression for a simple conditional.
const LIST_AND
Combine list with AND clauses.
selectSQLText( $tables, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Take the same arguments as IDatabase::select() and return the SQL it would use.
buildSubString( $input, $startPosition, $length=null)
Build a SUBSTRING function.
const QUERY_IGNORE_DBO_TRX
Ignore the current presence of any DBO_TRX flag.
getInfinity()
Find out when 'infinity' is.
const QUERY_CHANGE_SCHEMA
Query is a Data Definition Language command.
const QUERY_CHANGE_NONE
Query is a read-only Data Query Language query.
getTableAliases()
Return current table aliases.
const LIST_NAMES
Treat as field name and do not apply value escaping.
const QUERY_REPLICA_ROLE
Enforce that a query does not make effective writes.
const LIST_COMMA
Combine list with comma delimiters.
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
const LIST_OR
Combine list with OR clauses.
buildLike( $param,... $params)
LIKE statement wrapper.
addIdentifierQuotes( $s)
Escape a SQL identifier (e.g.
factorConds( $condsArray)
Given an array of condition arrays representing an OR list of AND lists, for example:
tableNames(... $tables)
Fetch a number of table names into an associative array.
const QUERY_PSEUDO_PERMANENT
Track a TEMPORARY table CREATE as if it was for a permanent table (for testing)
const QUERY_CHANGE_LOCKS
Query is a command for advisory locks.
unionSupportsOrderAndLimit()
Determine if the RDBMS supports ORDER BY and LIMIT for separate subqueries within UNION.
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
const QUERY_CHANGE_TRX
Query is a Transaction Control Language command (BEGIN, USE, SET, ...)
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
const QUERY_SILENCE_ERRORS
Ignore query errors and return false when they happen.
buildComparison(string $op, array $conds)
Build a condition comparing multiple values, for use with indexes that cover multiple fields,...
const ALL_ROWS
Unconditional update/delete of whole table.
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a "OR" condition with pairs from a two-dimensional array.
setSchemaVars( $vars)
Set schema variables to be used when streaming commands from SQL files or stdin.
buildSelectSubquery( $tables, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Equivalent to IDatabase::selectSQLText() except wraps the result in Subquery.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
buildGroupConcatField( $delim, $tables, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.