MediaWiki  master
ISQLPlatform.php
Go to the documentation of this file.
1 <?php
21 
25 
33 interface ISQLPlatform {
34 
36  public const LIST_COMMA = 0;
38  public const LIST_AND = 1;
40  public const LIST_SET = 2;
42  public const LIST_NAMES = 3;
44  public const LIST_OR = 4;
45 
47  public const ALL_ROWS = '*';
48 
50  public const QUERY_NORMAL = 0;
52  public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
54  public const QUERY_PSEUDO_PERMANENT = 2;
56  public const QUERY_REPLICA_ROLE = 4;
58  public const QUERY_IGNORE_DBO_TRX = 8;
60  public const QUERY_NO_RETRY = 16;
62  public const QUERY_CHANGE_NONE = 32;
64  public const QUERY_CHANGE_TRX = 64 | self::QUERY_IGNORE_DBO_TRX;
66  public const QUERY_CHANGE_ROWS = 128;
68  public const QUERY_CHANGE_SCHEMA = 256 | self::QUERY_IGNORE_DBO_TRX;
70  public const QUERY_CHANGE_LOCKS = 512 | self::QUERY_IGNORE_DBO_TRX;
71 
76  public function bitNot( $field );
77 
83  public function bitAnd( $fieldLeft, $fieldRight );
84 
90  public function bitOr( $fieldLeft, $fieldRight );
91 
101  public function addIdentifierQuotes( $s );
102 
117  public function buildGreatest( $fields, $values );
118 
133  public function buildLeast( $fields, $values );
134 
160  public function makeList( array $a, $mode = self::LIST_COMMA );
161 
178  public function makeWhereFrom2d( $data, $baseKey, $subKey );
179 
209  public function factorConds( $condsArray );
210 
216  public function buildConcat( $stringList );
217 
235  public function limitResult( $sql, $limit, $offset = false );
236 
256  public function buildLike( $param, ...$params );
257 
263  public function anyChar();
264 
270  public function anyString();
271 
277  public function unionSupportsOrderAndLimit();
278 
288  public function unionQueries( $sqls, $all );
289 
301  public function timestamp( $ts = 0 );
302 
317  public function timestampOrNull( $ts = null );
318 
326  public function getInfinity();
327 
334  public function encodeExpiry( $expiry );
335 
343  public function decodeExpiry( $expiry, $format = TS_MW );
344 
355  public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
356 
365  public function strreplace( $orig, $old, $new );
366 
379  public function buildSubString( $input, $startPosition, $length = null );
380 
386  public function buildStringCast( $field );
387 
393  public function buildIntegerCast( $field );
394 
401  public function implicitOrderby();
402 
416  public function setTableAliases( array $aliases );
417 
430  public function setIndexAliases( array $aliases );
431 
437  public function getTableAliases();
438 
456  public function selectSQLText(
457  $table,
458  $vars,
459  $conds = '',
460  $fname = __METHOD__,
461  $options = [],
462  $join_conds = []
463  );
464 
484  public function tableName( $name, $format = 'quoted' );
485 
502  public function tableNames( ...$tables );
503 
520  public function tableNamesN( ...$tables );
521 
548  public function unionConditionPermutations(
549  $table,
550  $vars,
551  array $permute_conds,
552  $extra_conds = '',
553  $fname = __METHOD__,
554  $options = [],
555  $join_conds = []
556  );
557 
574  public function buildGroupConcatField(
575  $delim, $table, $field, $conds = '', $join_conds = []
576  );
577 
592  public function buildSelectSubquery(
593  $table,
594  $vars,
595  $conds = '',
596  $fname = __METHOD__,
597  $options = [],
598  $join_conds = []
599  );
600 
618  public function buildExcludedValue( $column );
619 
627  public function setSchemaVars( $vars );
628 }
const LIST_NAMES
Definition: Defines.php:45
const LIST_COMMA
Definition: Defines.php:42
const LIST_SET
Definition: Defines.php:44
const LIST_OR
Definition: Defines.php:46
const LIST_AND
Definition: Defines.php:43
Database error base class.
Definition: DBError.php:31
Used by Database::buildLike() to represent characters that have special meaning in SQL LIKE clauses a...
Definition: LikeMatch.php:10
Interface for query language.
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
bitOr( $fieldLeft, $fieldRight)
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.
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.
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)
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Take the same arguments as IDatabase::select() and return the SQL it would use.
buildLeast( $fields, $values)
Build a LEAST function statement comparing columns/values.
conditional( $cond, $caseTrueExpression, $caseFalseExpression)
Returns an SQL expression for a simple conditional.
tableName( $name, $format='quoted')
Format a table name ready for use in constructing an SQL query.
buildSubString( $input, $startPosition, $length=null)
Build a SUBSTRING function.
getInfinity()
Find out when 'infinity' is.
getTableAliases()
Return current table aliases.
buildSelectSubquery( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Equivalent to IDatabase::selectSQLText() except wraps the result in Subquery.
unionConditionPermutations( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Construct a UNION query for permutations of conditions.
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
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:
unionQueries( $sqls, $all)
Construct a UNION query.
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)
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.
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
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 partial where clause from a 2-d array such as used for LinkBatch.
setSchemaVars( $vars)
Set schema variables to be used when streaming commands from SQL files or stdin.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s