MediaWiki master
ISQLPlatform.php
Go to the documentation of this file.
1<?php
7
13use Wikimedia\Timestamp\TimestampFormat as TS;
14
22interface ISQLPlatform {
23
25 public const LIST_COMMA = 0;
27 public const LIST_AND = 1;
29 public const LIST_SET = 2;
31 public const LIST_NAMES = 3;
33 public const LIST_OR = 4;
34
36 public const ALL_ROWS = '*';
37
39 public const QUERY_NORMAL = 0;
41 public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
43 public const QUERY_PSEUDO_PERMANENT = 2;
45 public const QUERY_REPLICA_ROLE = 4;
47 public const QUERY_IGNORE_DBO_TRX = 8;
49 public const QUERY_NO_RETRY = 16;
51 public const QUERY_CHANGE_NONE = 32;
53 public const QUERY_CHANGE_TRX = 64;
55 public const QUERY_CHANGE_ROWS = 128;
57 public const QUERY_CHANGE_SCHEMA = 256;
59 public const QUERY_CHANGE_LOCKS = 512;
60
66 public const CALLER_SUBQUERY = 'subquery';
67
72 public const CALLER_UNKNOWN = 'unknown';
73
78 public function bitNot( $field );
79
85 public function bitAnd( $fieldLeft, $fieldRight );
86
92 public function bitOr( $fieldLeft, $fieldRight );
93
105 public function addIdentifierQuotes( $s );
106
121 public function buildGreatest( $fields, $values );
122
137 public function buildLeast( $fields, $values );
138
167 public function buildComparison( string $op, array $conds ): string;
168
197 public function makeList( array $a, $mode = self::LIST_COMMA );
198
229 public function makeWhereFrom2d( $data, $baseKey, $subKey );
230
260 public function factorConds( $condsArray );
261
267 public function buildConcat( $stringList );
268
276 public function buildGroupConcat( $field, $delim ): string;
277
295 public function limitResult( $sql, $limit, $offset = false );
296
324 public function buildLike( $param, ...$params );
325
331 public function anyChar();
332
338 public function anyString();
339
345 public function unionSupportsOrderAndLimit();
346
361 public function unionQueries( $sqls, $all, $options = [] );
362
374 public function timestamp( $ts = 0 );
375
390 public function timestampOrNull( $ts = null );
391
399 public function getInfinity();
400
407 public function encodeExpiry( $expiry );
408
416 public function decodeExpiry( $expiry, $format = TS::MW );
417
429 public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
430
439 public function strreplace( $orig, $old, $new );
440
453 public function buildSubString( $input, $startPosition, $length = null );
454
460 public function buildStringCast( $field );
461
467 public function buildIntegerCast( $field );
468
475 public function implicitOrderby();
476
490 public function setTableAliases( array $aliases );
491
497 public function getTableAliases();
498
526 public function selectSQLText(
527 $tables,
528 $vars,
529 $conds = '',
530 $fname = __METHOD__,
531 $options = [],
532 $join_conds = []
533 );
534
561 public function tableName( string $name, $format = 'quoted' );
562
582 public function tableNamesN( ...$tables );
583
603 public function buildGroupConcatField(
604 $delim, $tables, $field, $conds = '', $join_conds = []
605 );
606
622 public function buildSelectSubquery(
623 $tables,
624 $vars,
625 $conds = '',
626 $fname = __METHOD__,
627 $options = [],
628 $join_conds = []
629 );
630
648 public function buildExcludedValue( $column );
649
657 public function setSchemaVars( $vars );
658}
Database error base class.
Definition DBError.php:22
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.
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.
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.
decodeExpiry( $expiry, $format=TS::MW)
Decode an expiry time into a DBMS independent format.
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:
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.
buildGroupConcat( $field, $delim)
Build a GROUP_CONCAT expression.
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.