MediaWiki  1.32.5
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-internal';
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 assertNoOpenTransactions();
173 
180  public function tablePrefix( $prefix = null );
181 
187  public function dbSchema( $schema = null );
188 
198  public function getLBInfo( $name = null );
199 
208  public function setLBInfo( $name, $value = null );
209 
216  public function setLazyMasterHandle( IDatabase $conn );
217 
224  public function implicitGroupby();
225 
232  public function implicitOrderby();
233 
238  public function lastQuery();
239 
247  public function doneWrites();
248 
256  public function lastDoneWrites();
257 
262  public function writesPending();
263 
268  public function preCommitCallbacksPending();
269 
278  public function writesOrCallbacksPending();
279 
289  public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL );
290 
297  public function pendingWriteCallers();
298 
305  public function pendingWriteRowsAffected();
306 
311  public function isOpen();
312 
325  public function setFlag( $flag, $remember = self::REMEMBER_NOTHING );
326 
339  public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING );
340 
347  public function restoreFlags( $state = self::RESTORE_PRIOR );
348 
359  public function getFlag( $flag );
360 
368  public function getDomainID();
369 
376  public function getWikiID();
377 
383  public function getType();
384 
395  public function fetchObject( $res );
396 
406  public function fetchRow( $res );
407 
415  public function numRows( $res );
416 
424  public function numFields( $res );
425 
434  public function fieldName( $res, $n );
435 
445  public function insertId();
446 
454  public function dataSeek( $res, $row );
455 
462  public function lastErrno();
463 
470  public function lastError();
471 
478  public function affectedRows();
479 
488  public function getSoftwareLink();
489 
496  public function getServerVersion();
497 
508  public function close();
509 
536  public function query( $sql, $fname = __METHOD__, $tempIgnore = false );
537 
545  public function freeResult( $res );
546 
566  public function selectField(
567  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
568  );
569 
590  public function selectFieldValues(
591  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
592  );
593 
761  public function select(
762  $table, $vars, $conds = '', $fname = __METHOD__,
763  $options = [], $join_conds = []
764  );
765 
782  public function selectSQLText(
783  $table, $vars, $conds = '', $fname = __METHOD__,
784  $options = [], $join_conds = []
785  );
786 
802  public function selectRow( $table, $vars, $conds, $fname = __METHOD__,
803  $options = [], $join_conds = []
804  );
805 
828  public function estimateRowCount(
829  $table, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
830  );
831 
850  public function selectRowCount(
851  $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
852  );
853 
865  public function lockForUpdate(
866  $table, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
867  );
868 
878  public function fieldExists( $table, $field, $fname = __METHOD__ );
879 
891  public function indexExists( $table, $index, $fname = __METHOD__ );
892 
901  public function tableExists( $table, $fname = __METHOD__ );
902 
937  public function insert( $table, $a, $fname = __METHOD__, $options = [] );
938 
960  public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] );
961 
987  public function makeList( $a, $mode = self::LIST_COMMA );
988 
999  public function makeWhereFrom2d( $data, $baseKey, $subKey );
1000 
1009  public function aggregateValue( $valuedata, $valuename = 'value' );
1010 
1015  public function bitNot( $field );
1016 
1022  public function bitAnd( $fieldLeft, $fieldRight );
1023 
1029  public function bitOr( $fieldLeft, $fieldRight );
1030 
1037  public function buildConcat( $stringList );
1038 
1055  public function buildGroupConcatField(
1056  $delim, $table, $field, $conds = '', $join_conds = []
1057  );
1058 
1071  public function buildSubString( $input, $startPosition, $length = null );
1072 
1078  public function buildStringCast( $field );
1079 
1085  public function buildIntegerCast( $field );
1086 
1101  public function buildSelectSubquery(
1102  $table, $vars, $conds = '', $fname = __METHOD__,
1103  $options = [], $join_conds = []
1104  );
1105 
1117  public function databasesAreIndependent();
1118 
1130  public function selectDB( $db );
1131 
1143  public function selectDomain( $domain );
1144 
1149  public function getDBname();
1150 
1155  public function getServer();
1156 
1163  public function addQuotes( $s );
1164 
1181  public function buildLike();
1182 
1188  public function anyChar();
1189 
1195  public function anyString();
1196 
1213  public function nextSequenceValue( $seqName );
1214 
1238  public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ );
1239 
1277  public function upsert(
1278  $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__
1279  );
1280 
1301  public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
1302  $fname = __METHOD__
1303  );
1304 
1316  public function delete( $table, $conds, $fname = __METHOD__ );
1317 
1354  public function insertSelect( $destTable, $srcTable, $varMap, $conds,
1355  $fname = __METHOD__,
1356  $insertOptions = [], $selectOptions = [], $selectJoinConds = []
1357  );
1358 
1364  public function unionSupportsOrderAndLimit();
1365 
1374  public function unionQueries( $sqls, $all );
1375 
1402  public function unionConditionPermutations(
1403  $table, $vars, array $permute_conds, $extra_conds = '', $fname = __METHOD__,
1404  $options = [], $join_conds = []
1405  );
1406 
1416  public function conditional( $cond, $trueVal, $falseVal );
1417 
1428  public function strreplace( $orig, $old, $new );
1429 
1436  public function getServerUptime();
1437 
1445  public function wasDeadlock();
1446 
1454  public function wasLockTimeout();
1455 
1464  public function wasConnectionLoss();
1465 
1471  public function wasReadOnlyError();
1472 
1480  public function wasErrorReissuable();
1481 
1492  public function masterPosWait( DBMasterPos $pos, $timeout );
1493 
1500  public function getReplicaPos();
1501 
1508  public function getMasterPos();
1509 
1514  public function serverIsReadOnly();
1515 
1535  public function onTransactionResolution( callable $callback, $fname = __METHOD__ );
1536 
1569  public function onTransactionCommitOrIdle( callable $callback, $fname = __METHOD__ );
1570 
1580  public function onTransactionIdle( callable $callback, $fname = __METHOD__ );
1581 
1605  public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ );
1606 
1625  public function setTransactionListener( $name, callable $callback = null );
1626 
1701  public function startAtomic( $fname = __METHOD__, $cancelable = self::ATOMIC_NOT_CANCELABLE );
1702 
1714  public function endAtomic( $fname = __METHOD__ );
1715 
1741  public function cancelAtomic( $fname = __METHOD__, AtomicSectionIdentifier $sectionId = null );
1742 
1815  public function doAtomicSection(
1816  $fname, callable $callback, $cancelable = self::ATOMIC_NOT_CANCELABLE
1817  );
1818 
1839  public function begin( $fname = __METHOD__, $mode = self::TRANSACTION_EXPLICIT );
1840 
1861  public function commit( $fname = __METHOD__, $flush = '' );
1862 
1883  public function rollback( $fname = __METHOD__, $flush = '' );
1884 
1897  public function flushSnapshot( $fname = __METHOD__ );
1898 
1910  public function timestamp( $ts = 0 );
1911 
1925  public function timestampOrNull( $ts = null );
1926 
1933  public function ping( &$rtt = null );
1934 
1943  public function getLag();
1944 
1959  public function getSessionLagStatus();
1960 
1966  public function maxListLen();
1967 
1977  public function encodeBlob( $b );
1978 
1987  public function decodeBlob( $b );
1988 
2000  public function setSessionOptions( array $options );
2001 
2009  public function setSchemaVars( $vars );
2010 
2020  public function lockIsFree( $lockName, $method );
2021 
2033  public function lock( $lockName, $method, $timeout = 5 );
2034 
2049  public function unlock( $lockName, $method );
2050 
2072  public function getScopedLockAndFlush( $lockKey, $fname, $timeout );
2073 
2080  public function namedLocksEnqueue();
2081 
2089  public function getInfinity();
2090 
2097  public function encodeExpiry( $expiry );
2098 
2106  public function decodeExpiry( $expiry, $format = TS_MW );
2107 
2117  public function setBigSelects( $value = true );
2118 
2123  public function isReadOnly();
2124 
2138  public function setTableAliases( array $aliases );
2139 
2153  public function setIndexAliases( array $aliases );
2154 }
2155 
2159 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.
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.
Wikimedia\Rdbms\IDatabase\getInfinity
getInfinity()
Find out when 'infinity' is.
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.
Wikimedia\Rdbms\IDatabase\numRows
numRows( $res)
Get the number of rows in a query result.
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.
$tables
this hook is for auditing only 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:1018
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\onTransactionCommitOrIdle
onTransactionCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
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:35
LIST_AND
const LIST_AND
Definition: Defines.php:43
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:46
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:141
Wikimedia\Rdbms\IDatabase\lockForUpdate
lockForUpdate( $table, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Lock all rows meeting the given conditions/options FOR UPDATE.
LIST_SET
const LIST_SET
Definition: Defines.php:44
Wikimedia\Rdbms\IDatabase\databasesAreIndependent
databasesAreIndependent()
Returns true if DBs are assumed to be on potentially different servers.
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
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.
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2278
Wikimedia\Rdbms\IDatabase\preCommitCallbacksPending
preCommitCallbacksPending()
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.
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
Wikimedia\Rdbms\IDatabase\wasLockTimeout
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
Wikimedia\Rdbms\IDatabase\assertNoOpenTransactions
assertNoOpenTransactions()
Assert that all explicit transactions or atomic sections have been closed.
LIST_COMMA
const LIST_COMMA
Definition: Defines.php:42
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:121
Wikimedia\Rdbms\IDatabase\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Wikimedia\Rdbms\IDatabase\buildSubString
buildSubString( $input, $startPosition, $length=null)
Build a SUBSTRING function.
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
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:49
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()
Return the currently selected domain ID.
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 after 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__)
Alias for onTransactionCommitOrIdle() for backwards-compatibility.
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.
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,...
$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:2683
Wikimedia\Rdbms\IDatabase\setSchemaVars
setSchemaVars( $vars)
Set variables to be used in sourceFile/sourceStream, in preference to the ones in $GLOBALS.
$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:2044
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.
Wikimedia\Rdbms\IDatabase\selectDomain
selectDomain( $domain)
Set the current domain (database, schema, and table prefix)
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:52
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:45
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()
Whether there is a transaction open with either possible write queries or unresolved pre-commit/commi...