MediaWiki master
ISQLPlatform.php
Go to the documentation of this file.
1<?php
7
14use Wikimedia\Timestamp\TimestampFormat as TS;
15
23interface ISQLPlatform {
24
26 public const LIST_COMMA = 0;
28 public const LIST_AND = 1;
30 public const LIST_SET = 2;
32 public const LIST_NAMES = 3;
34 public const LIST_OR = 4;
35
37 public const ALL_ROWS = '*';
38
40 public const QUERY_NORMAL = 0;
42 public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
44 public const QUERY_PSEUDO_PERMANENT = 2;
46 public const QUERY_REPLICA_ROLE = 4;
48 public const QUERY_IGNORE_DBO_TRX = 8;
50 public const QUERY_NO_RETRY = 16;
52 public const QUERY_CHANGE_NONE = 32;
54 public const QUERY_CHANGE_TRX = 64;
56 public const QUERY_CHANGE_ROWS = 128;
58 public const QUERY_CHANGE_SCHEMA = 256;
60 public const QUERY_CHANGE_LOCKS = 512;
61
67 public const CALLER_SUBQUERY = 'subquery';
68
73 public const CALLER_UNKNOWN = 'unknown';
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
277 public function buildGroupConcat( $field, $delim ): string;
278
296 public function limitResult( $sql, $limit, $offset = false );
297
325 public function buildLike( $param, ...$params );
326
332 public function anyChar();
333
339 public function anyString();
340
346 public function unionSupportsOrderAndLimit();
347
362 public function unionQueries( $sqls, $all, $options = [] );
363
375 public function timestamp( $ts = 0 );
376
391 public function timestampOrNull( $ts = null );
392
400 public function getInfinity();
401
408 public function encodeExpiry( $expiry );
409
417 public function decodeExpiry( $expiry, $format = TS::MW );
418
430 public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
431
440 public function strreplace( $orig, $old, $new );
441
454 public function buildSubString( $input, $startPosition, $length = null );
455
461 public function buildStringCast( $field );
462
468 public function buildIntegerCast( $field );
469
476 public function implicitOrderby();
477
491 public function setTableAliases( array $aliases );
492
498 public function getTableAliases();
499
527 public function selectSQLText(
528 $tables,
529 $vars,
530 $conds = '',
531 $fname = __METHOD__,
532 $options = [],
533 $join_conds = []
534 );
535
562 public function tableName( string $name, $format = 'quoted' );
563
583 public function tableNamesN( ...$tables );
584
604 public function buildGroupConcatField(
605 $delim, $tables, $field, $conds = '', $join_conds = []
606 );
607
623 public function buildSelectSubquery(
624 $tables,
625 $vars,
626 $conds = '',
627 $fname = __METHOD__,
628 $options = [],
629 $join_conds = []
630 );
631
649 public function buildExcludedValue( $column );
650
658 public function setSchemaVars( $vars );
659}
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.