MediaWiki  REL1_31
IDatabase.php
Go to the documentation of this file.
1 <?php
20 namespace Wikimedia\Rdbms;
21 
22 use InvalidArgumentException;
23 use Wikimedia\ScopedCallback;
24 use RuntimeException;
25 use stdClass;
26 
38 interface IDatabase {
40  const TRIGGER_IDLE = 1;
42  const TRIGGER_COMMIT = 2;
44  const TRIGGER_ROLLBACK = 3;
45 
47  const TRANSACTION_EXPLICIT = '';
49  const TRANSACTION_INTERNAL = 'implicit';
50 
52  const ATOMIC_NOT_CANCELABLE = '';
54  const ATOMIC_CANCELABLE = 'cancelable';
55 
57  const FLUSHING_ONE = '';
59  const FLUSHING_ALL_PEERS = 'flush';
61  const FLUSHING_INTERNAL = 'flush';
62 
64  const REMEMBER_NOTHING = '';
66  const REMEMBER_PRIOR = 'remember';
68  const RESTORE_PRIOR = 'prior';
70  const RESTORE_INITIAL = 'initial';
71 
73  const ESTIMATE_TOTAL = 'total';
75  const ESTIMATE_DB_APPLY = 'apply';
76 
78  const LIST_COMMA = 0;
80  const LIST_AND = 1;
82  const LIST_SET = 2;
84  const LIST_NAMES = 3;
86  const LIST_OR = 4;
87 
89  const DBO_DEBUG = 1;
91  const DBO_NOBUFFER = 2;
93  const DBO_IGNORE = 4;
95  const DBO_TRX = 8;
97  const DBO_DEFAULT = 16;
99  const DBO_PERSISTENT = 32;
101  const DBO_SYSDBA = 64;
103  const DBO_DDLMODE = 128;
105  const DBO_SSL = 256;
107  const DBO_COMPRESS = 512;
108 
116  public function getServerInfo();
117 
138  public function bufferResults( $buffer = null );
139 
148  public function trxLevel();
149 
159  public function trxTimestamp();
160 
165  public function explicitTrxActive();
166 
172  public function tablePrefix( $prefix = null );
173 
179  public function dbSchema( $schema = null );
180 
190  public function getLBInfo( $name = null );
191 
200  public function setLBInfo( $name, $value = null );
201 
208  public function setLazyMasterHandle( IDatabase $conn );
209 
216  public function implicitGroupby();
217 
224  public function implicitOrderby();
225 
230  public function lastQuery();
231 
239  public function doneWrites();
240 
248  public function lastDoneWrites();
249 
254  public function writesPending();
255 
263  public function writesOrCallbacksPending();
264 
274  public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL );
275 
282  public function pendingWriteCallers();
283 
290  public function pendingWriteRowsAffected();
291 
296  public function isOpen();
297 
310  public function setFlag( $flag, $remember = self::REMEMBER_NOTHING );
311 
324  public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING );
325 
332  public function restoreFlags( $state = self::RESTORE_PRIOR );
333 
344  public function getFlag( $flag );
345 
349  public function getDomainID();
350 
357  public function getWikiID();
358 
364  public function getType();
365 
376  public function open( $server, $user, $password, $dbName );
377 
388  public function fetchObject( $res );
389 
399  public function fetchRow( $res );
400 
407  public function numRows( $res );
408 
416  public function numFields( $res );
417 
426  public function fieldName( $res, $n );
427 
437  public function insertId();
438 
446  public function dataSeek( $res, $row );
447 
454  public function lastErrno();
455 
462  public function lastError();
463 
470  public function affectedRows();
471 
480  public function getSoftwareLink();
481 
488  public function getServerVersion();
489 
500  public function close();
501 
528  public function query( $sql, $fname = __METHOD__, $tempIgnore = false );
529 
537  public function freeResult( $res );
538 
558  public function selectField(
559  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
560  );
561 
582  public function selectFieldValues(
583  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
584  );
585 
751  public function select(
752  $table, $vars, $conds = '', $fname = __METHOD__,
753  $options = [], $join_conds = []
754  );
755 
772  public function selectSQLText(
773  $table, $vars, $conds = '', $fname = __METHOD__,
774  $options = [], $join_conds = []
775  );
776 
792  public function selectRow( $table, $vars, $conds, $fname = __METHOD__,
793  $options = [], $join_conds = []
794  );
795 
818  public function estimateRowCount(
819  $table, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
820  );
821 
840  public function selectRowCount(
841  $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
842  );
843 
853  public function fieldExists( $table, $field, $fname = __METHOD__ );
854 
866  public function indexExists( $table, $index, $fname = __METHOD__ );
867 
876  public function tableExists( $table, $fname = __METHOD__ );
877 
912  public function insert( $table, $a, $fname = __METHOD__, $options = [] );
913 
935  public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] );
936 
962  public function makeList( $a, $mode = self::LIST_COMMA );
963 
974  public function makeWhereFrom2d( $data, $baseKey, $subKey );
975 
984  public function aggregateValue( $valuedata, $valuename = 'value' );
985 
990  public function bitNot( $field );
991 
997  public function bitAnd( $fieldLeft, $fieldRight );
998 
1004  public function bitOr( $fieldLeft, $fieldRight );
1005 
1012  public function buildConcat( $stringList );
1013 
1030  public function buildGroupConcatField(
1031  $delim, $table, $field, $conds = '', $join_conds = []
1032  );
1033 
1046  public function buildSubString( $input, $startPosition, $length = null );
1047 
1053  public function buildStringCast( $field );
1054 
1060  public function buildIntegerCast( $field );
1061 
1076  public function buildSelectSubquery(
1077  $table, $vars, $conds = '', $fname = __METHOD__,
1078  $options = [], $join_conds = []
1079  );
1080 
1092  public function databasesAreIndependent();
1093 
1101  public function selectDB( $db );
1102 
1107  public function getDBname();
1108 
1113  public function getServer();
1114 
1121  public function addQuotes( $s );
1122 
1139  public function buildLike();
1140 
1146  public function anyChar();
1147 
1153  public function anyString();
1154 
1171  public function nextSequenceValue( $seqName );
1172 
1196  public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ );
1197 
1234  public function upsert(
1235  $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__
1236  );
1237 
1258  public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
1259  $fname = __METHOD__
1260  );
1261 
1273  public function delete( $table, $conds, $fname = __METHOD__ );
1274 
1311  public function insertSelect( $destTable, $srcTable, $varMap, $conds,
1312  $fname = __METHOD__,
1313  $insertOptions = [], $selectOptions = [], $selectJoinConds = []
1314  );
1315 
1321  public function unionSupportsOrderAndLimit();
1322 
1331  public function unionQueries( $sqls, $all );
1332 
1360  $table, $vars, array $permute_conds, $extra_conds = '', $fname = __METHOD__,
1361  $options = [], $join_conds = []
1362  );
1363 
1373  public function conditional( $cond, $trueVal, $falseVal );
1374 
1385  public function strreplace( $orig, $old, $new );
1386 
1393  public function getServerUptime();
1394 
1402  public function wasDeadlock();
1403 
1411  public function wasLockTimeout();
1412 
1421  public function wasConnectionLoss();
1422 
1428  public function wasReadOnlyError();
1429 
1437  public function wasErrorReissuable();
1438 
1449  public function masterPosWait( DBMasterPos $pos, $timeout );
1450 
1457  public function getReplicaPos();
1458 
1465  public function getMasterPos();
1466 
1471  public function serverIsReadOnly();
1472 
1491  public function onTransactionResolution( callable $callback, $fname = __METHOD__ );
1492 
1521  public function onTransactionIdle( callable $callback, $fname = __METHOD__ );
1522 
1543  public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ );
1544 
1560  public function setTransactionListener( $name, callable $callback = null );
1561 
1636  public function startAtomic( $fname = __METHOD__, $cancelable = self::ATOMIC_NOT_CANCELABLE );
1637 
1649  public function endAtomic( $fname = __METHOD__ );
1650 
1676  public function cancelAtomic( $fname = __METHOD__, AtomicSectionIdentifier $sectionId = null );
1677 
1750  public function doAtomicSection(
1751  $fname, callable $callback, $cancelable = self::ATOMIC_NOT_CANCELABLE
1752  );
1753 
1774  public function begin( $fname = __METHOD__, $mode = self::TRANSACTION_EXPLICIT );
1775 
1796  public function commit( $fname = __METHOD__, $flush = '' );
1797 
1818  public function rollback( $fname = __METHOD__, $flush = '' );
1819 
1832  public function flushSnapshot( $fname = __METHOD__ );
1833 
1845  public function timestamp( $ts = 0 );
1846 
1860  public function timestampOrNull( $ts = null );
1861 
1868  public function ping( &$rtt = null );
1869 
1878  public function getLag();
1879 
1894  public function getSessionLagStatus();
1895 
1901  public function maxListLen();
1902 
1912  public function encodeBlob( $b );
1913 
1922  public function decodeBlob( $b );
1923 
1935  public function setSessionOptions( array $options );
1936 
1944  public function setSchemaVars( $vars );
1945 
1955  public function lockIsFree( $lockName, $method );
1956 
1968  public function lock( $lockName, $method, $timeout = 5 );
1969 
1984  public function unlock( $lockName, $method );
1985 
2007  public function getScopedLockAndFlush( $lockKey, $fname, $timeout );
2008 
2015  public function namedLocksEnqueue();
2016 
2024  public function getInfinity();
2025 
2032  public function encodeExpiry( $expiry );
2033 
2041  public function decodeExpiry( $expiry, $format = TS_MW );
2042 
2052  public function setBigSelects( $value = true );
2053 
2058  public function isReadOnly();
2059 
2073  public function setTableAliases( array $aliases );
2074 
2088  public function setIndexAliases( array $aliases );
2089 }
2090 
2091 class_alias( IDatabase::class, 'IDatabase' );
DBO_PERSISTENT
const DBO_PERSISTENT
Definition: defines.php:14
Wikimedia\Rdbms\IDatabase\flushSnapshot
flushSnapshot( $fname=__METHOD__)
Commit any transaction but error out if writes or callbacks are pending.
Wikimedia\Rdbms\IDatabase\query
query( $sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:247
Wikimedia\Rdbms\IDatabase\isOpen
isOpen()
Is a connection to the database open?
Wikimedia\Rdbms\IDatabase\affectedRows
affectedRows()
Get the number of rows affected by the last write query.
Wikimedia\Rdbms\IDatabase\setBigSelects
setBigSelects( $value=true)
Allow or deny "big selects" for this session only.
Wikimedia\Rdbms\IDatabase\getServer
getServer()
Get the server hostname or IP address.
Wikimedia\Rdbms\IDatabase\getServerVersion
getServerVersion()
A string describing the current software version, like from mysql_get_server_info().
Wikimedia\Rdbms\IDatabase\maxListLen
maxListLen()
Return the maximum number of items allowed in a list, or 0 for unlimited.
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
Wikimedia\Rdbms\IDatabase\getInfinity
getInfinity()
Find out when 'infinity' is.
$rows
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition: hooks.txt:2783
Wikimedia\Rdbms\IDatabase\insertSelect
insertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[], $selectJoinConds=[])
INSERT SELECT wrapper.
Wikimedia\Rdbms\IDatabase\unionQueries
unionQueries( $sqls, $all)
Construct a UNION query This is used for providing overload point for other DB abstractions not compa...
Wikimedia\Rdbms\IDatabase\pendingWriteQueryDuration
pendingWriteQueryDuration( $type=self::ESTIMATE_TOTAL)
Get the time spend running write queries for this transaction.
Wikimedia\Rdbms\IDatabase\tablePrefix
tablePrefix( $prefix=null)
Get/set the table prefix.
Wikimedia\Rdbms\IDatabase\writesPending
writesPending()
Wikimedia\Rdbms\IDatabase\makeList
makeList( $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Wikimedia\Rdbms\IDatabase\numRows
numRows( $res)
Get the number of rows in a result object.
Wikimedia\Rdbms\IDatabase\cancelAtomic
cancelAtomic( $fname=__METHOD__, AtomicSectionIdentifier $sectionId=null)
Cancel an atomic section of SQL statements.
Wikimedia\Rdbms\IDatabase\ping
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
Wikimedia\Rdbms\IDatabase\numFields
numFields( $res)
Get the number of fields in a result object.
Wikimedia\Rdbms\IDatabase\getWikiID
getWikiID()
Alias for getDomainID()
Wikimedia\Rdbms\IDatabase\bitNot
bitNot( $field)
Wikimedia\Rdbms\IDatabase\getMasterPos
getMasterPos()
Get the position of this master.
Wikimedia\Rdbms\IDatabase\wasErrorReissuable
wasErrorReissuable()
Determines if the last query error was due to something outside of the query itself.
Wikimedia\Rdbms\IDatabase\encodeExpiry
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
Wikimedia\Rdbms\IDatabase\lastError
lastError()
Get a description of the last error.
DBO_DEBUG
const DBO_DEBUG
Definition: defines.php:9
Wikimedia\Rdbms\IDatabase\replace
replace( $table, $uniqueIndexes, $rows, $fname=__METHOD__)
REPLACE query wrapper.
Wikimedia\Rdbms\IDatabase\endAtomic
endAtomic( $fname=__METHOD__)
Ends an atomic section of SQL statements.
Wikimedia\Rdbms\IDatabase\trxLevel
trxLevel()
Gets the current transaction level.
Wikimedia\Rdbms\IDatabase\close
close()
Close the database connection.
Wikimedia\Rdbms\IDatabase\implicitOrderby
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\IDatabase\getServerInfo
getServerInfo()
A string describing the current software version, and possibly other details in a user-friendly way.
Wikimedia\Rdbms\DBMasterPos
An object representing a master or replica DB position in a replicated setup.
Definition: DBMasterPos.php:12
Wikimedia\Rdbms\IDatabase\trxTimestamp
trxTimestamp()
Get the UNIX timestamp of the time that the transaction was established.
$s
$s
Definition: mergeMessageFileList.php:187
Wikimedia\Rdbms\IDatabase\doneWrites
doneWrites()
Returns true if the connection may have been used for write queries.
DBO_SSL
const DBO_SSL
Definition: defines.php:17
$res
$res
Definition: database.txt:21
DBO_IGNORE
const DBO_IGNORE
Definition: defines.php:11
Wikimedia\Rdbms\IDatabase\decodeBlob
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
Wikimedia\Rdbms\IDatabase\getSessionLagStatus
getSessionLagStatus()
Get the replica DB lag when the current transaction started or a general lag estimate if not transact...
Wikimedia\Rdbms\IDatabase\selectField
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
Wikimedia\Rdbms\IDatabase\getLag
getLag()
Get the amount of replication lag for this database server.
Wikimedia\Rdbms\IDatabase\isReadOnly
isReadOnly()
Wikimedia\Rdbms\IDatabase\insert
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
Wikimedia\Rdbms\IDatabase\bufferResults
bufferResults( $buffer=null)
Turns buffering of SQL result sets on (true) or off (false).
DBO_TRX
const DBO_TRX
Definition: defines.php:12
Wikimedia\Rdbms\IDatabase\dbSchema
dbSchema( $schema=null)
Get/set the db schema.
Wikimedia\Rdbms\IDatabase\tableExists
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists.
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
LIST_AND
const LIST_AND
Definition: Defines.php:53
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\IDatabase\fieldName
fieldName( $res, $n)
Get a field name in a result object.
Wikimedia\Rdbms\IDatabase\lastDoneWrites
lastDoneWrites()
Returns the last time the connection may have been used for write queries.
DBO_NOBUFFER
const DBO_NOBUFFER
Definition: defines.php:10
Wikimedia\Rdbms\IDatabase\commit
commit( $fname=__METHOD__, $flush='')
Commits a transaction previously started using begin().
Wikimedia\Rdbms\IDatabase\fetchObject
fetchObject( $res)
Fetch the next row from the given result object, in object form.
Wikimedia\Rdbms\IDatabase\getServerUptime
getServerUptime()
Determines how long the server has been up.
Wikimedia\Rdbms\IDatabase\lock
lock( $lockName, $method, $timeout=5)
Acquire a named lock.
Wikimedia\Rdbms\IDatabase\buildSelectSubquery
buildSelectSubquery( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Equivalent to IDatabase::selectSQLText() except wraps the result in Subqyery.
Wikimedia\Rdbms\IDatabase\unionSupportsOrderAndLimit
unionSupportsOrderAndLimit()
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within th...
Wikimedia\Rdbms\IDatabase\implicitGroupby
implicitGroupby()
Returns true if this database does an implicit sort when doing GROUP BY.
Wikimedia\Rdbms\IDatabase\getSoftwareLink
getSoftwareLink()
Returns a wikitext link to the DB's website, e.g., return "[https://www.mysql.com/ MySQL]"; Should at...
Wikimedia\Rdbms\IDatabase\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
LIST_OR
const LIST_OR
Definition: Defines.php:56
Wikimedia\Rdbms\IDatabase\freeResult
freeResult( $res)
Free a result object returned by query() or select().
Wikimedia\Rdbms\IDatabase\encodeBlob
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
Wikimedia\Rdbms\IDatabase\deleteJoin
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
Wikimedia\Rdbms\IDatabase\estimateRowCount
estimateRowCount( $table, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Estimate the number of rows in dataset.
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:145
LIST_SET
const LIST_SET
Definition: Defines.php:54
Wikimedia\Rdbms\IDatabase\databasesAreIndependent
databasesAreIndependent()
Returns true if DBs are assumed to be on potentially different servers.
Wikimedia\Rdbms\IDatabase\buildLike
buildLike()
LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match conta...
Wikimedia\Rdbms\IDatabase\wasDeadlock
wasDeadlock()
Determines if the last failure was due to a deadlock.
Wikimedia\Rdbms\IDatabase\anyChar
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
Wikimedia\Rdbms\IDatabase\open
open( $server, $user, $password, $dbName)
Open a new connection to the database (closing any existing one)
Wikimedia\Rdbms\IDatabase\decodeExpiry
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
Wikimedia\Rdbms\IDatabase\setIndexAliases
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
Wikimedia\Rdbms\IDatabase\wasLockTimeout
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
LIST_COMMA
const LIST_COMMA
Definition: Defines.php:52
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:112
Wikimedia\Rdbms\IDatabase\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:2001
Wikimedia\Rdbms\IDatabase\buildSubString
buildSubString( $input, $startPosition, $length=null)
Build a SUBSTRING function.
Wikimedia\Rdbms\IDatabase\setLBInfo
setLBInfo( $name, $value=null)
Set the LB info array, or a member of it.
DBO_COMPRESS
const DBO_COMPRESS
Definition: defines.php:18
$value
$value
Definition: styleTest.css.php:45
Wikimedia\Rdbms\IDatabase\unlock
unlock( $lockName, $method)
Release a lock.
Wikimedia\Rdbms\IDatabase\lastQuery
lastQuery()
Return the last query that went through IDatabase::query()
Wikimedia\Rdbms\IDatabase\selectRow
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Single row SELECT wrapper.
DBO_DDLMODE
const DBO_DDLMODE
Definition: defines.php:16
Wikimedia\Rdbms\IDatabase\getScopedLockAndFlush
getScopedLockAndFlush( $lockKey, $fname, $timeout)
Acquire a named lock, flush any transaction, and return an RAII style unlocker object.
Wikimedia\Rdbms\IDatabase\selectRowCount
selectRowCount( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
Wikimedia\Rdbms\IDatabase\explicitTrxActive
explicitTrxActive()
Wikimedia\Rdbms\IDatabase\buildStringCast
buildStringCast( $field)
Wikimedia\Rdbms\IDatabase\getDomainID
getDomainID()
Wikimedia\Rdbms\IDatabase\buildConcat
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.
Wikimedia\Rdbms\IDatabase\wasConnectionLoss
wasConnectionLoss()
Determines if the last query error was due to a dropped connection.
Wikimedia\Rdbms\IDatabase\setTransactionListener
setTransactionListener( $name, callable $callback=null)
Run a callback each time any transaction commits or rolls back.
Wikimedia\Rdbms\AtomicSectionIdentifier
Class used for token representing identifiers for atomic sections from IDatabase instances.
Definition: AtomicSectionIdentifier.php:26
Wikimedia\Rdbms\IDatabase\getDBname
getDBname()
Get the current DB name.
Wikimedia\Rdbms\IDatabase\wasReadOnlyError
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
Wikimedia\Rdbms\IDatabase\strreplace
strreplace( $orig, $old, $new)
Returns a command for str_replace function in SQL query.
Wikimedia\Rdbms\IDatabase\bitOr
bitOr( $fieldLeft, $fieldRight)
Wikimedia\Rdbms\IDatabase\rollback
rollback( $fname=__METHOD__, $flush='')
Rollback a transaction previously started using begin().
Wikimedia\Rdbms\IDatabase\pendingWriteCallers
pendingWriteCallers()
Get the list of method names that did write queries for this transaction.
Wikimedia\Rdbms\IDatabase\fetchRow
fetchRow( $res)
Fetch the next row from the given result object, in associative array form.
DBO_SYSDBA
const DBO_SYSDBA
Definition: defines.php:15
Wikimedia\Rdbms\IDatabase\anyString
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
Wikimedia\Rdbms\IDatabase\upsert
upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname=__METHOD__)
INSERT ON DUPLICATE KEY UPDATE wrapper, upserts an array into a table.
Wikimedia\Rdbms\IDatabase\update
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
Wikimedia\Rdbms\IDatabase\getReplicaPos
getReplicaPos()
Get the replication position of this replica DB.
Wikimedia\Rdbms\IDatabase\getFlag
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
Wikimedia\Rdbms\IDatabase\masterPosWait
masterPosWait(DBMasterPos $pos, $timeout)
Wait for the replica DB to catch up to a given master position.
Wikimedia\Rdbms\IDatabase\onTransactionIdle
onTransactionIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
Wikimedia\Rdbms\IDatabase\bitAnd
bitAnd( $fieldLeft, $fieldRight)
Wikimedia\Rdbms\IDatabase\lockIsFree
lockIsFree( $lockName, $method)
Check to see if a named lock is not locked by any thread (non-blocking)
Wikimedia\Rdbms\IDatabase\selectDB
selectDB( $db)
Change the current database.
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
Wikimedia\Rdbms\IDatabase\doAtomicSection
doAtomicSection( $fname, callable $callback, $cancelable=self::ATOMIC_NOT_CANCELABLE)
Perform an atomic section of reversable SQL statements from a callback.
Wikimedia\Rdbms\IDatabase\lastErrno
lastErrno()
Get the last error number.
Wikimedia\Rdbms\IDatabase\fieldExists
fieldExists( $table, $field, $fname=__METHOD__)
Determines whether a field exists in a table.
Wikimedia\Rdbms\IDatabase\aggregateValue
aggregateValue( $valuedata, $valuename='value')
Return aggregated value alias.
Wikimedia\Rdbms\IDatabase\selectSQLText
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
The equivalent of IDatabase::select() except that the constructed SQL is returned,...
Wikimedia\Rdbms\IDatabase\setSchemaVars
setSchemaVars( $vars)
Set variables to be used in sourceFile/sourceStream, in preference to the ones in $GLOBALS.
Wikimedia\Rdbms\IDatabase\addQuotes
addQuotes( $s)
Adds quotes and backslashes.
Wikimedia\Rdbms\IDatabase\unionConditionPermutations
unionConditionPermutations( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Construct a UNION query for permutations of conditions.
$tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:1015
Wikimedia\Rdbms\IDatabase\onTransactionPreCommitOrIdle
onTransactionPreCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback before the current transaction commits or now if there is none.
Wikimedia\Rdbms\IDatabase\makeWhereFrom2d
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a partial where clause from a 2-d array such as used for LinkBatch.
Wikimedia\Rdbms\IDatabase\selectFieldValues
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
Wikimedia\Rdbms\IDatabase\getType
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
Wikimedia\Rdbms\IDatabase\select
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
Wikimedia\Rdbms\IDatabase\getLBInfo
getLBInfo( $name=null)
Get properties passed down from the server info array of the load balancer.
Wikimedia\Rdbms\IDatabase\timestampOrNull
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
Wikimedia\Rdbms\IDatabase\buildGroupConcatField
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
Wikimedia\Rdbms\IDatabase\serverIsReadOnly
serverIsReadOnly()
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:56
Wikimedia\Rdbms\IDatabase\dataSeek
dataSeek( $res, $row)
Change the position of the cursor in a result object.
Wikimedia\Rdbms\IDatabase\buildIntegerCast
buildIntegerCast( $field)
LIST_NAMES
const LIST_NAMES
Definition: Defines.php:55
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2228
Wikimedia\Rdbms\IDatabase\insertId
insertId()
Get the inserted value of an auto-increment row.
Wikimedia\Rdbms\IDatabase\setLazyMasterHandle
setLazyMasterHandle(IDatabase $conn)
Set a lazy-connecting DB handle to the master DB (for replication status purposes)
Wikimedia\Rdbms\IDatabase\onTransactionResolution
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.
Wikimedia\Rdbms\IDatabase\setSessionOptions
setSessionOptions(array $options)
Override database's default behavior.
Wikimedia\Rdbms\IDatabase\conditional
conditional( $cond, $trueVal, $falseVal)
Returns an SQL expression for a simple conditional.
DBO_DEFAULT
const DBO_DEFAULT
Definition: defines.php:13
Wikimedia\Rdbms\IDatabase\setFlag
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
Wikimedia\Rdbms\IDatabase\nextSequenceValue
nextSequenceValue( $seqName)
Deprecated method, calls should be removed.
Wikimedia\Rdbms\IDatabase\restoreFlags
restoreFlags( $state=self::RESTORE_PRIOR)
Restore the flags to their prior state before the last setFlag/clearFlag call.
Wikimedia\Rdbms\IDatabase\begin
begin( $fname=__METHOD__, $mode=self::TRANSACTION_EXPLICIT)
Begin a transaction.
$buffer
$buffer
Definition: mwdoc-filter.php:49
Wikimedia\Rdbms\IDatabase\indexExists
indexExists( $table, $index, $fname=__METHOD__)
Determines whether an index exists Usually throws a DBQueryError on failure If errors are explicitly ...
Wikimedia\Rdbms\IDatabase\clearFlag
clearFlag( $flag, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
Wikimedia\Rdbms\IDatabase\pendingWriteRowsAffected
pendingWriteRowsAffected()
Get the number of affected rows from pending write queries.
Wikimedia\Rdbms\IDatabase\namedLocksEnqueue
namedLocksEnqueue()
Check to see if a named lock used by lock() use blocking queues.
$type
$type
Definition: testCompression.php:48
Wikimedia\Rdbms\IDatabase\startAtomic
startAtomic( $fname=__METHOD__, $cancelable=self::ATOMIC_NOT_CANCELABLE)
Begin an atomic section of SQL statements.
Wikimedia\Rdbms\IDatabase\writesOrCallbacksPending
writesOrCallbacksPending()
Returns true if there is a transaction/round open with possible write queries or transaction pre-comm...