MediaWiki master
ISQLPlatform.php
Go to the documentation of this file.
1<?php
21
26
34interface ISQLPlatform {
35
37 public const LIST_COMMA = 0;
39 public const LIST_AND = 1;
41 public const LIST_SET = 2;
43 public const LIST_NAMES = 3;
45 public const LIST_OR = 4;
46
48 public const ALL_ROWS = '*';
49
51 public const QUERY_NORMAL = 0;
53 public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
55 public const QUERY_PSEUDO_PERMANENT = 2;
57 public const QUERY_REPLICA_ROLE = 4;
59 public const QUERY_IGNORE_DBO_TRX = 8;
61 public const QUERY_NO_RETRY = 16;
63 public const QUERY_CHANGE_NONE = 32;
65 public const QUERY_CHANGE_TRX = 64 | self::QUERY_IGNORE_DBO_TRX;
67 public const QUERY_CHANGE_ROWS = 128;
69 public const QUERY_CHANGE_SCHEMA = 256 | self::QUERY_IGNORE_DBO_TRX;
71 public const QUERY_CHANGE_LOCKS = 512 | self::QUERY_IGNORE_DBO_TRX;
73 public const QUERY_CREATE_TEMP = 1024;
74
79 public function bitNot( $field );
80
86 public function bitAnd( $fieldLeft, $fieldRight );
87
93 public function bitOr( $fieldLeft, $fieldRight );
94
106 public function addIdentifierQuotes( $s );
107
122 public function buildGreatest( $fields, $values );
123
138 public function buildLeast( $fields, $values );
139
168 public function buildComparison( string $op, array $conds ): string;
169
198 public function makeList( array $a, $mode = self::LIST_COMMA );
199
230 public function makeWhereFrom2d( $data, $baseKey, $subKey );
231
261 public function factorConds( $condsArray );
262
268 public function buildConcat( $stringList );
269
287 public function limitResult( $sql, $limit, $offset = false );
288
311 public function buildLike( $param, ...$params );
312
318 public function anyChar();
319
325 public function anyString();
326
332 public function unionSupportsOrderAndLimit();
333
348 public function unionQueries( $sqls, $all, $options = [] );
349
361 public function timestamp( $ts = 0 );
362
377 public function timestampOrNull( $ts = null );
378
386 public function getInfinity();
387
394 public function encodeExpiry( $expiry );
395
403 public function decodeExpiry( $expiry, $format = TS_MW );
404
415 public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
416
425 public function strreplace( $orig, $old, $new );
426
439 public function buildSubString( $input, $startPosition, $length = null );
440
446 public function buildStringCast( $field );
447
453 public function buildIntegerCast( $field );
454
461 public function implicitOrderby();
462
476 public function setTableAliases( array $aliases );
477
490 public function setIndexAliases( array $aliases );
491
497 public function getTableAliases();
498
523 public function selectSQLText(
524 $table,
525 $vars,
526 $conds = '',
527 $fname = __METHOD__,
528 $options = [],
529 $join_conds = []
530 );
531
551 public function tableName( string $name, $format = 'quoted' );
552
574 public function tableNames( ...$tables );
575
594 public function tableNamesN( ...$tables );
595
612 public function buildGroupConcatField(
613 $delim, $table, $field, $conds = '', $join_conds = []
614 );
615
630 public function buildSelectSubquery(
631 $table,
632 $vars,
633 $conds = '',
634 $fname = __METHOD__,
635 $options = [],
636 $join_conds = []
637 );
638
656 public function buildExcludedValue( $column );
657
665 public function setSchemaVars( $vars );
666}
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
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
Interface for query language.
unionQueries( $sqls, $all, $options=[])
Construct a UNION query.
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.
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)
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.
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.
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:
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...
buildComparison(string $op, array $conds)
Build a condition comparing multiple values, for use with indexes that cover multiple fields,...
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.
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.