MediaWiki master
ISQLPlatform.php
Go to the documentation of this file.
1<?php
21
27
35interface ISQLPlatform {
36
38 public const LIST_COMMA = 0;
40 public const LIST_AND = 1;
42 public const LIST_SET = 2;
44 public const LIST_NAMES = 3;
46 public const LIST_OR = 4;
47
49 public const ALL_ROWS = '*';
50
52 public const QUERY_NORMAL = 0;
54 public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
56 public const QUERY_PSEUDO_PERMANENT = 2;
58 public const QUERY_REPLICA_ROLE = 4;
60 public const QUERY_IGNORE_DBO_TRX = 8;
62 public const QUERY_NO_RETRY = 16;
64 public const QUERY_CHANGE_NONE = 32;
66 public const QUERY_CHANGE_TRX = 64;
68 public const QUERY_CHANGE_ROWS = 128;
70 public const QUERY_CHANGE_SCHEMA = 256;
72 public const QUERY_CHANGE_LOCKS = 512;
73
79 public const CALLER_SUBQUERY = 'subquery';
80
85 public const CALLER_UNKNOWN = 'unknown';
86
91 public function bitNot( $field );
92
98 public function bitAnd( $fieldLeft, $fieldRight );
99
105 public function bitOr( $fieldLeft, $fieldRight );
106
118 public function addIdentifierQuotes( $s );
119
134 public function buildGreatest( $fields, $values );
135
150 public function buildLeast( $fields, $values );
151
180 public function buildComparison( string $op, array $conds ): string;
181
210 public function makeList( array $a, $mode = self::LIST_COMMA );
211
242 public function makeWhereFrom2d( $data, $baseKey, $subKey );
243
273 public function factorConds( $condsArray );
274
280 public function buildConcat( $stringList );
281
299 public function limitResult( $sql, $limit, $offset = false );
300
323 public function buildLike( $param, ...$params );
324
330 public function anyChar();
331
337 public function anyString();
338
344 public function unionSupportsOrderAndLimit();
345
360 public function unionQueries( $sqls, $all, $options = [] );
361
373 public function timestamp( $ts = 0 );
374
389 public function timestampOrNull( $ts = null );
390
398 public function getInfinity();
399
406 public function encodeExpiry( $expiry );
407
415 public function decodeExpiry( $expiry, $format = TS_MW );
416
428 public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
429
438 public function strreplace( $orig, $old, $new );
439
452 public function buildSubString( $input, $startPosition, $length = null );
453
459 public function buildStringCast( $field );
460
466 public function buildIntegerCast( $field );
467
474 public function implicitOrderby();
475
489 public function setTableAliases( array $aliases );
490
503 public function setIndexAliases( array $aliases );
504
510 public function getTableAliases();
511
539 public function selectSQLText(
540 $tables,
541 $vars,
542 $conds = '',
543 $fname = __METHOD__,
544 $options = [],
545 $join_conds = []
546 );
547
574 public function tableName( string $name, $format = 'quoted' );
575
595 public function tableNamesN( ...$tables );
596
616 public function buildGroupConcatField(
617 $delim, $tables, $field, $conds = '', $join_conds = []
618 );
619
635 public function buildSelectSubquery(
636 $tables,
637 $vars,
638 $conds = '',
639 $fname = __METHOD__,
640 $options = [],
641 $join_conds = []
642 );
643
661 public function buildExcludedValue( $column );
662
670 public function setSchemaVars( $vars );
671}
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
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.
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
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.
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)
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.
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.
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.