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
319 public function buildLike( $param, ...$params );
320
326 public function anyChar();
327
333 public function anyString();
334
340 public function unionSupportsOrderAndLimit();
341
356 public function unionQueries( $sqls, $all, $options = [] );
357
369 public function timestamp( $ts = 0 );
370
385 public function timestampOrNull( $ts = null );
386
394 public function getInfinity();
395
402 public function encodeExpiry( $expiry );
403
411 public function decodeExpiry( $expiry, $format = TS::MW );
412
424 public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
425
434 public function strreplace( $orig, $old, $new );
435
448 public function buildSubString( $input, $startPosition, $length = null );
449
455 public function buildStringCast( $field );
456
462 public function buildIntegerCast( $field );
463
470 public function implicitOrderby();
471
485 public function setTableAliases( array $aliases );
486
492 public function getTableAliases();
493
521 public function selectSQLText(
522 $tables,
523 $vars,
524 $conds = '',
525 $fname = __METHOD__,
526 $options = [],
527 $join_conds = []
528 );
529
556 public function tableName( string $name, $format = 'quoted' );
557
577 public function tableNamesN( ...$tables );
578
598 public function buildGroupConcatField(
599 $delim, $tables, $field, $conds = '', $join_conds = []
600 );
601
617 public function buildSelectSubquery(
618 $tables,
619 $vars,
620 $conds = '',
621 $fname = __METHOD__,
622 $options = [],
623 $join_conds = []
624 );
625
643 public function buildExcludedValue( $column );
644
652 public function setSchemaVars( $vars );
653}
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.