MediaWiki REL1_30
DBConnRef.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
5use InvalidArgumentException;
6
15class DBConnRef implements IDatabase {
17 private $lb;
19 private $conn;
21 private $params;
22
23 const FLD_INDEX = 0;
24 const FLD_GROUP = 1;
25 const FLD_DOMAIN = 2;
26 const FLD_FLAGS = 3;
27
32 public function __construct( ILoadBalancer $lb, $conn ) {
33 $this->lb = $lb;
34 if ( $conn instanceof Database ) {
35 $this->conn = $conn; // live handle
36 } elseif ( count( $conn ) >= 4 && $conn[self::FLD_DOMAIN] !== false ) {
37 $this->params = $conn;
38 } else {
39 throw new InvalidArgumentException( "Missing lazy connection arguments." );
40 }
41 }
42
43 function __call( $name, array $arguments ) {
44 if ( $this->conn === null ) {
45 list( $db, $groups, $wiki, $flags ) = $this->params;
46 $this->conn = $this->lb->getConnection( $db, $groups, $wiki, $flags );
47 }
48
49 return call_user_func_array( [ $this->conn, $name ], $arguments );
50 }
51
52 public function getServerInfo() {
53 return $this->__call( __FUNCTION__, func_get_args() );
54 }
55
56 public function bufferResults( $buffer = null ) {
57 return $this->__call( __FUNCTION__, func_get_args() );
58 }
59
60 public function trxLevel() {
61 return $this->__call( __FUNCTION__, func_get_args() );
62 }
63
64 public function trxTimestamp() {
65 return $this->__call( __FUNCTION__, func_get_args() );
66 }
67
68 public function explicitTrxActive() {
69 return $this->__call( __FUNCTION__, func_get_args() );
70 }
71
72 public function tablePrefix( $prefix = null ) {
73 return $this->__call( __FUNCTION__, func_get_args() );
74 }
75
76 public function dbSchema( $schema = null ) {
77 return $this->__call( __FUNCTION__, func_get_args() );
78 }
79
80 public function getLBInfo( $name = null ) {
81 return $this->__call( __FUNCTION__, func_get_args() );
82 }
83
84 public function setLBInfo( $name, $value = null ) {
85 return $this->__call( __FUNCTION__, func_get_args() );
86 }
87
88 public function setLazyMasterHandle( IDatabase $conn ) {
89 return $this->__call( __FUNCTION__, func_get_args() );
90 }
91
92 public function implicitGroupby() {
93 return $this->__call( __FUNCTION__, func_get_args() );
94 }
95
96 public function implicitOrderby() {
97 return $this->__call( __FUNCTION__, func_get_args() );
98 }
99
100 public function lastQuery() {
101 return $this->__call( __FUNCTION__, func_get_args() );
102 }
103
104 public function doneWrites() {
105 return $this->__call( __FUNCTION__, func_get_args() );
106 }
107
108 public function lastDoneWrites() {
109 return $this->__call( __FUNCTION__, func_get_args() );
110 }
111
112 public function writesPending() {
113 return $this->__call( __FUNCTION__, func_get_args() );
114 }
115
116 public function writesOrCallbacksPending() {
117 return $this->__call( __FUNCTION__, func_get_args() );
118 }
119
120 public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL ) {
121 return $this->__call( __FUNCTION__, func_get_args() );
122 }
123
124 public function pendingWriteCallers() {
125 return $this->__call( __FUNCTION__, func_get_args() );
126 }
127
128 public function pendingWriteRowsAffected() {
129 return $this->__call( __FUNCTION__, func_get_args() );
130 }
131
132 public function isOpen() {
133 return $this->__call( __FUNCTION__, func_get_args() );
134 }
135
136 public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
137 return $this->__call( __FUNCTION__, func_get_args() );
138 }
139
140 public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
141 return $this->__call( __FUNCTION__, func_get_args() );
142 }
143
144 public function restoreFlags( $state = self::RESTORE_PRIOR ) {
145 return $this->__call( __FUNCTION__, func_get_args() );
146 }
147
148 public function getFlag( $flag ) {
149 return $this->__call( __FUNCTION__, func_get_args() );
150 }
151
152 public function getProperty( $name ) {
153 return $this->__call( __FUNCTION__, func_get_args() );
154 }
155
156 public function getDomainID() {
157 if ( $this->conn === null ) {
158 $domain = $this->params[self::FLD_DOMAIN];
159 // Avoid triggering a database connection
160 return $domain instanceof DatabaseDomain ? $domain->getId() : $domain;
161 }
162
163 return $this->__call( __FUNCTION__, func_get_args() );
164 }
165
166 public function getWikiID() {
167 return $this->getDomainID();
168 }
169
170 public function getType() {
171 return $this->__call( __FUNCTION__, func_get_args() );
172 }
173
174 public function open( $server, $user, $password, $dbName ) {
175 return $this->__call( __FUNCTION__, func_get_args() );
176 }
177
178 public function fetchObject( $res ) {
179 return $this->__call( __FUNCTION__, func_get_args() );
180 }
181
182 public function fetchRow( $res ) {
183 return $this->__call( __FUNCTION__, func_get_args() );
184 }
185
186 public function numRows( $res ) {
187 return $this->__call( __FUNCTION__, func_get_args() );
188 }
189
190 public function numFields( $res ) {
191 return $this->__call( __FUNCTION__, func_get_args() );
192 }
193
194 public function fieldName( $res, $n ) {
195 return $this->__call( __FUNCTION__, func_get_args() );
196 }
197
198 public function insertId() {
199 return $this->__call( __FUNCTION__, func_get_args() );
200 }
201
202 public function dataSeek( $res, $row ) {
203 return $this->__call( __FUNCTION__, func_get_args() );
204 }
205
206 public function lastErrno() {
207 return $this->__call( __FUNCTION__, func_get_args() );
208 }
209
210 public function lastError() {
211 return $this->__call( __FUNCTION__, func_get_args() );
212 }
213
214 public function fieldInfo( $table, $field ) {
215 return $this->__call( __FUNCTION__, func_get_args() );
216 }
217
218 public function affectedRows() {
219 return $this->__call( __FUNCTION__, func_get_args() );
220 }
221
222 public function getSoftwareLink() {
223 return $this->__call( __FUNCTION__, func_get_args() );
224 }
225
226 public function getServerVersion() {
227 return $this->__call( __FUNCTION__, func_get_args() );
228 }
229
230 public function close() {
231 return $this->__call( __FUNCTION__, func_get_args() );
232 }
233
234 public function reportConnectionError( $error = 'Unknown error' ) {
235 return $this->__call( __FUNCTION__, func_get_args() );
236 }
237
238 public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
239 return $this->__call( __FUNCTION__, func_get_args() );
240 }
241
242 public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
243 return $this->__call( __FUNCTION__, func_get_args() );
244 }
245
246 public function freeResult( $res ) {
247 return $this->__call( __FUNCTION__, func_get_args() );
248 }
249
250 public function selectField(
251 $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
252 ) {
253 return $this->__call( __FUNCTION__, func_get_args() );
254 }
255
256 public function selectFieldValues(
257 $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
258 ) {
259 return $this->__call( __FUNCTION__, func_get_args() );
260 }
261
262 public function select(
263 $table, $vars, $conds = '', $fname = __METHOD__,
264 $options = [], $join_conds = []
265 ) {
266 return $this->__call( __FUNCTION__, func_get_args() );
267 }
268
269 public function selectSQLText(
270 $table, $vars, $conds = '', $fname = __METHOD__,
271 $options = [], $join_conds = []
272 ) {
273 return $this->__call( __FUNCTION__, func_get_args() );
274 }
275
276 public function selectRow(
277 $table, $vars, $conds, $fname = __METHOD__,
278 $options = [], $join_conds = []
279 ) {
280 return $this->__call( __FUNCTION__, func_get_args() );
281 }
282
283 public function estimateRowCount(
284 $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = []
285 ) {
286 return $this->__call( __FUNCTION__, func_get_args() );
287 }
288
289 public function selectRowCount(
290 $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
291 ) {
292 return $this->__call( __FUNCTION__, func_get_args() );
293 }
294
295 public function fieldExists( $table, $field, $fname = __METHOD__ ) {
296 return $this->__call( __FUNCTION__, func_get_args() );
297 }
298
299 public function indexExists( $table, $index, $fname = __METHOD__ ) {
300 return $this->__call( __FUNCTION__, func_get_args() );
301 }
302
303 public function tableExists( $table, $fname = __METHOD__ ) {
304 return $this->__call( __FUNCTION__, func_get_args() );
305 }
306
307 public function indexUnique( $table, $index ) {
308 return $this->__call( __FUNCTION__, func_get_args() );
309 }
310
311 public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
312 return $this->__call( __FUNCTION__, func_get_args() );
313 }
314
315 public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] ) {
316 return $this->__call( __FUNCTION__, func_get_args() );
317 }
318
319 public function makeList( $a, $mode = self::LIST_COMMA ) {
320 return $this->__call( __FUNCTION__, func_get_args() );
321 }
322
323 public function makeWhereFrom2d( $data, $baseKey, $subKey ) {
324 return $this->__call( __FUNCTION__, func_get_args() );
325 }
326
327 public function aggregateValue( $valuedata, $valuename = 'value' ) {
328 return $this->__call( __FUNCTION__, func_get_args() );
329 }
330
331 public function bitNot( $field ) {
332 return $this->__call( __FUNCTION__, func_get_args() );
333 }
334
335 public function bitAnd( $fieldLeft, $fieldRight ) {
336 return $this->__call( __FUNCTION__, func_get_args() );
337 }
338
339 public function bitOr( $fieldLeft, $fieldRight ) {
340 return $this->__call( __FUNCTION__, func_get_args() );
341 }
342
343 public function buildConcat( $stringList ) {
344 return $this->__call( __FUNCTION__, func_get_args() );
345 }
346
347 public function buildGroupConcatField(
348 $delim, $table, $field, $conds = '', $join_conds = []
349 ) {
350 return $this->__call( __FUNCTION__, func_get_args() );
351 }
352
353 public function buildStringCast( $field ) {
354 return $this->__call( __FUNCTION__, func_get_args() );
355 }
356
357 public function databasesAreIndependent() {
358 return $this->__call( __FUNCTION__, func_get_args() );
359 }
360
361 public function selectDB( $db ) {
362 return $this->__call( __FUNCTION__, func_get_args() );
363 }
364
365 public function getDBname() {
366 return $this->__call( __FUNCTION__, func_get_args() );
367 }
368
369 public function getServer() {
370 return $this->__call( __FUNCTION__, func_get_args() );
371 }
372
373 public function addQuotes( $s ) {
374 return $this->__call( __FUNCTION__, func_get_args() );
375 }
376
377 public function buildLike() {
378 return $this->__call( __FUNCTION__, func_get_args() );
379 }
380
381 public function anyChar() {
382 return $this->__call( __FUNCTION__, func_get_args() );
383 }
384
385 public function anyString() {
386 return $this->__call( __FUNCTION__, func_get_args() );
387 }
388
389 public function nextSequenceValue( $seqName ) {
390 return $this->__call( __FUNCTION__, func_get_args() );
391 }
392
393 public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) {
394 return $this->__call( __FUNCTION__, func_get_args() );
395 }
396
397 public function upsert(
398 $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__
399 ) {
400 return $this->__call( __FUNCTION__, func_get_args() );
401 }
402
403 public function deleteJoin(
404 $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = __METHOD__
405 ) {
406 return $this->__call( __FUNCTION__, func_get_args() );
407 }
408
409 public function delete( $table, $conds, $fname = __METHOD__ ) {
410 return $this->__call( __FUNCTION__, func_get_args() );
411 }
412
413 public function insertSelect(
414 $destTable, $srcTable, $varMap, $conds,
415 $fname = __METHOD__, $insertOptions = [], $selectOptions = [], $selectJoinConds = []
416 ) {
417 return $this->__call( __FUNCTION__, func_get_args() );
418 }
419
420 public function unionSupportsOrderAndLimit() {
421 return $this->__call( __FUNCTION__, func_get_args() );
422 }
423
424 public function unionQueries( $sqls, $all ) {
425 return $this->__call( __FUNCTION__, func_get_args() );
426 }
427
429 $table, $vars, array $permute_conds, $extra_conds = '', $fname = __METHOD__,
430 $options = [], $join_conds = []
431 ) {
432 return $this->__call( __FUNCTION__, func_get_args() );
433 }
434
435 public function conditional( $cond, $trueVal, $falseVal ) {
436 return $this->__call( __FUNCTION__, func_get_args() );
437 }
438
439 public function strreplace( $orig, $old, $new ) {
440 return $this->__call( __FUNCTION__, func_get_args() );
441 }
442
443 public function getServerUptime() {
444 return $this->__call( __FUNCTION__, func_get_args() );
445 }
446
447 public function wasDeadlock() {
448 return $this->__call( __FUNCTION__, func_get_args() );
449 }
450
451 public function wasLockTimeout() {
452 return $this->__call( __FUNCTION__, func_get_args() );
453 }
454
455 public function wasErrorReissuable() {
456 return $this->__call( __FUNCTION__, func_get_args() );
457 }
458
459 public function wasReadOnlyError() {
460 return $this->__call( __FUNCTION__, func_get_args() );
461 }
462
463 public function masterPosWait( DBMasterPos $pos, $timeout ) {
464 return $this->__call( __FUNCTION__, func_get_args() );
465 }
466
467 public function getReplicaPos() {
468 return $this->__call( __FUNCTION__, func_get_args() );
469 }
470
471 public function getMasterPos() {
472 return $this->__call( __FUNCTION__, func_get_args() );
473 }
474
475 public function serverIsReadOnly() {
476 return $this->__call( __FUNCTION__, func_get_args() );
477 }
478
479 public function onTransactionResolution( callable $callback, $fname = __METHOD__ ) {
480 return $this->__call( __FUNCTION__, func_get_args() );
481 }
482
483 public function onTransactionIdle( callable $callback, $fname = __METHOD__ ) {
484 return $this->__call( __FUNCTION__, func_get_args() );
485 }
486
487 public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
488 return $this->__call( __FUNCTION__, func_get_args() );
489 }
490
491 public function setTransactionListener( $name, callable $callback = null ) {
492 return $this->__call( __FUNCTION__, func_get_args() );
493 }
494
495 public function startAtomic( $fname = __METHOD__ ) {
496 return $this->__call( __FUNCTION__, func_get_args() );
497 }
498
499 public function endAtomic( $fname = __METHOD__ ) {
500 return $this->__call( __FUNCTION__, func_get_args() );
501 }
502
503 public function doAtomicSection( $fname, callable $callback ) {
504 return $this->__call( __FUNCTION__, func_get_args() );
505 }
506
507 public function begin( $fname = __METHOD__, $mode = IDatabase::TRANSACTION_EXPLICIT ) {
508 return $this->__call( __FUNCTION__, func_get_args() );
509 }
510
511 public function commit( $fname = __METHOD__, $flush = '' ) {
512 return $this->__call( __FUNCTION__, func_get_args() );
513 }
514
515 public function rollback( $fname = __METHOD__, $flush = '' ) {
516 return $this->__call( __FUNCTION__, func_get_args() );
517 }
518
519 public function flushSnapshot( $fname = __METHOD__ ) {
520 return $this->__call( __FUNCTION__, func_get_args() );
521 }
522
523 public function listTables( $prefix = null, $fname = __METHOD__ ) {
524 return $this->__call( __FUNCTION__, func_get_args() );
525 }
526
527 public function timestamp( $ts = 0 ) {
528 return $this->__call( __FUNCTION__, func_get_args() );
529 }
530
531 public function timestampOrNull( $ts = null ) {
532 return $this->__call( __FUNCTION__, func_get_args() );
533 }
534
535 public function ping( &$rtt = null ) {
536 return func_num_args()
537 ? $this->__call( __FUNCTION__, [ &$rtt ] )
538 : $this->__call( __FUNCTION__, [] ); // method cares about null vs missing
539 }
540
541 public function getLag() {
542 return $this->__call( __FUNCTION__, func_get_args() );
543 }
544
545 public function getSessionLagStatus() {
546 return $this->__call( __FUNCTION__, func_get_args() );
547 }
548
549 public function maxListLen() {
550 return $this->__call( __FUNCTION__, func_get_args() );
551 }
552
553 public function encodeBlob( $b ) {
554 return $this->__call( __FUNCTION__, func_get_args() );
555 }
556
557 public function decodeBlob( $b ) {
558 return $this->__call( __FUNCTION__, func_get_args() );
559 }
560
561 public function setSessionOptions( array $options ) {
562 return $this->__call( __FUNCTION__, func_get_args() );
563 }
564
565 public function setSchemaVars( $vars ) {
566 return $this->__call( __FUNCTION__, func_get_args() );
567 }
568
569 public function lockIsFree( $lockName, $method ) {
570 return $this->__call( __FUNCTION__, func_get_args() );
571 }
572
573 public function lock( $lockName, $method, $timeout = 5 ) {
574 return $this->__call( __FUNCTION__, func_get_args() );
575 }
576
577 public function unlock( $lockName, $method ) {
578 return $this->__call( __FUNCTION__, func_get_args() );
579 }
580
581 public function getScopedLockAndFlush( $lockKey, $fname, $timeout ) {
582 return $this->__call( __FUNCTION__, func_get_args() );
583 }
584
585 public function namedLocksEnqueue() {
586 return $this->__call( __FUNCTION__, func_get_args() );
587 }
588
589 public function getInfinity() {
590 return $this->__call( __FUNCTION__, func_get_args() );
591 }
592
593 public function encodeExpiry( $expiry ) {
594 return $this->__call( __FUNCTION__, func_get_args() );
595 }
596
597 public function decodeExpiry( $expiry, $format = TS_MW ) {
598 return $this->__call( __FUNCTION__, func_get_args() );
599 }
600
601 public function setBigSelects( $value = true ) {
602 return $this->__call( __FUNCTION__, func_get_args() );
603 }
604
605 public function isReadOnly() {
606 return $this->__call( __FUNCTION__, func_get_args() );
607 }
608
609 public function setTableAliases( array $aliases ) {
610 return $this->__call( __FUNCTION__, func_get_args() );
611 }
612
616 function __destruct() {
617 if ( $this->conn ) {
618 $this->lb->reuseConnection( $this->conn );
619 }
620 }
621}
622
623class_alias( DBConnRef::class, 'DBConnRef' );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
Definition DBConnRef.php:15
__call( $name, array $arguments)
Definition DBConnRef.php:43
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
wasDeadlock()
Determines if the last failure was due to a deadlock.
buildGroupConcatField( $delim, $table, $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.
bitOr( $fieldLeft, $fieldRight)
open( $server, $user, $password, $dbName)
Open a connection to the database.
lastErrno()
Get the last error number.
flushSnapshot( $fname=__METHOD__)
Commit any transaction but error out if writes or callbacks are pending.
getReplicaPos()
Get the replication position of this replica DB.
setSchemaVars( $vars)
Set variables to be used in sourceFile/sourceStream, in preference to the ones in $GLOBALS.
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
numRows( $res)
Get the number of rows in a result object.
unionConditionPermutations( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Construct a UNION query for permutations of conditions.
estimateRowCount( $table, $vars=' *', $conds='', $fname=__METHOD__, $options=[])
Estimate the number of rows in dataset.
begin( $fname=__METHOD__, $mode=IDatabase::TRANSACTION_EXPLICIT)
Begin a transaction.
lockIsFree( $lockName, $method)
Check to see if a named lock is available (non-blocking)
fieldName( $res, $n)
Get a field name in a result object.
selectDB( $db)
Change the current database.
trxTimestamp()
Get the UNIX timestamp of the time that the transaction was established.
Definition DBConnRef.php:64
endAtomic( $fname=__METHOD__)
Ends an atomic section of SQL statements.
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
selectRowCount( $tables, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
numFields( $res)
Get the number of fields in a result object.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
makeList( $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
array null $params
N-tuple of (server index, group, DatabaseDomain|string)
Definition DBConnRef.php:21
getServer()
Get the server hostname or IP address.
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
getSoftwareLink()
Returns a wikitext link to the DB's website, e.g., return "[https://www.mysql.com/ MySQL]"; Should at...
lock( $lockName, $method, $timeout=5)
Acquire a named lock.
dataSeek( $res, $row)
Change the position of the cursor in a result object.
startAtomic( $fname=__METHOD__)
Begin an atomic section of statements.
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
lastQuery()
Return the last query that went through IDatabase::query()
indexUnique( $table, $index)
Determines if a given index is unique.
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
close()
Closes a database connection.
getSessionLagStatus()
Get the replica DB lag when the current transaction started or a general lag estimate if not transact...
masterPosWait(DBMasterPos $pos, $timeout)
Wait for the replica DB to catch up to a given master position.
isOpen()
Is a connection to the database open?
clearFlag( $flag, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
unlock( $lockName, $method)
Release a lock.
bufferResults( $buffer=null)
Turns buffering of SQL result sets on (true) or off (false).
Definition DBConnRef.php:56
getInfinity()
Find out when 'infinity' is.
getLBInfo( $name=null)
Get properties passed down from the server info array of the load balancer.
Definition DBConnRef.php:80
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Single row SELECT wrapper.
unionQueries( $sqls, $all)
Construct a UNION query This is used for providing overload point for other DB abstractions not compa...
pendingWriteQueryDuration( $type=self::ESTIMATE_TOTAL)
Get the time spend running write queries for this transaction.
maxListLen()
Return the maximum number of items allowed in a list, or 0 for unlimited.
fetchRow( $res)
Fetch the next row from the given result object, in associative array form.
onTransactionPreCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback before the current transaction commits or now if there is none.
setTransactionListener( $name, callable $callback=null)
Run a callback each time any transaction commits or rolls back.
__destruct()
Clean up the connection when out of scope.
setLBInfo( $name, $value=null)
Set the LB info array, or a member of it.
Definition DBConnRef.php:84
writesOrCallbacksPending()
Returns true if there is a transaction open with possible write queries or transaction pre-commit/idl...
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
setSessionOptions(array $options)
Override database's default behavior.
dbSchema( $schema=null)
Get/set the db schema.
Definition DBConnRef.php:76
getLag()
Get replica DB lag.
upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname=__METHOD__)
INSERT ON DUPLICATE KEY UPDATE wrapper, upserts an array into a table.
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
indexExists( $table, $index, $fname=__METHOD__)
Determines whether an index exists Usually throws a DBQueryError on failure If errors are explicitly ...
unionSupportsOrderAndLimit()
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within th...
nextSequenceValue( $seqName)
Deprecated method, calls should be removed.
freeResult( $res)
Free a result object returned by query() or select().
strreplace( $orig, $old, $new)
Returns a command for str_replace function in SQL query.
restoreFlags( $state=self::RESTORE_PRIOR)
Restore the flags to their prior state before the last setFlag/clearFlag call.
rollback( $fname=__METHOD__, $flush='')
Rollback a transaction previously started using begin().
doneWrites()
Returns true if the connection may have been used for write queries.
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
fieldExists( $table, $field, $fname=__METHOD__)
Determines whether a field exists in a table.
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
implicitGroupby()
Returns true if this database does an implicit sort when doing GROUP BY.
Definition DBConnRef.php:92
affectedRows()
Get the number of rows affected by the last write query.
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
Definition DBConnRef.php:96
setLazyMasterHandle(IDatabase $conn)
Set a lazy-connecting DB handle to the master DB (for replication status purposes)
Definition DBConnRef.php:88
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
fetchObject( $res)
Fetch the next row from the given result object, in object form.
bitAnd( $fieldLeft, $fieldRight)
namedLocksEnqueue()
Check to see if a named lock used by lock() use blocking queues.
getWikiID()
Alias for getDomainID()
insertId()
Get the inserted value of an auto-increment row.
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
The equivalent of IDatabase::select() except that the constructed SQL is returned,...
buildLike()
LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match conta...
getScopedLockAndFlush( $lockKey, $fname, $timeout)
Acquire a named lock, flush any transaction, and return an RAII style unlocker object.
wasErrorReissuable()
Determines if the last query error was due to a dropped connection and should be dealt with by pingin...
pendingWriteRowsAffected()
Get the number of affected rows from pending write queries.
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
conditional( $cond, $trueVal, $falseVal)
Returns an SQL expression for a simple conditional.
replace( $table, $uniqueIndexes, $rows, $fname=__METHOD__)
REPLACE query wrapper.
getDBname()
Get the current DB name.
reportConnectionError( $error='Unknown error')
getServerInfo()
A string describing the current software version, and possibly other details in a user-friendly way.
Definition DBConnRef.php:52
trxLevel()
Gets the current transaction level.
Definition DBConnRef.php:60
getServerUptime()
Determines how long the server has been up.
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
setBigSelects( $value=true)
Allow or deny "big selects" for this session only.
databasesAreIndependent()
Returns true if DBs are assumed to be on potentially different servers.
query( $sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
commit( $fname=__METHOD__, $flush='')
Commits a transaction previously started using begin().
getMasterPos()
Get the position of this master.
onTransactionIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
addQuotes( $s)
Adds quotes and backslashes.
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
fieldInfo( $table, $field)
mysql_fetch_field() wrapper Returns false if the field doesn't exist
doAtomicSection( $fname, callable $callback)
Run a callback to do an atomic set of updates for this database.
lastDoneWrites()
Returns the last time the connection may have been used for write queries.
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
reportQueryError( $error, $errno, $sql, $fname, $tempIgnore=false)
Report a query error.
Database null $conn
Live connection handle.
Definition DBConnRef.php:19
insertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[], $selectJoinConds=[])
INSERT SELECT wrapper.
lastError()
Get a description of the last error.
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a partial where clause from a 2-d array such as used for LinkBatch.
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists.
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
getServerVersion()
A string describing the current software version, like from mysql_get_server_info().
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.
aggregateValue( $valuedata, $valuename='value')
Return aggregated value alias.
__construct(ILoadBalancer $lb, $conn)
Definition DBConnRef.php:32
tablePrefix( $prefix=null)
Get/set the table prefix.
Definition DBConnRef.php:72
pendingWriteCallers()
Get the list of method names that did write queries for this transaction.
Class to handle database/prefix specification for IDatabase domains.
Relational database abstraction object.
Definition Database.php:45
$res
Definition database.txt:21
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
the array() calling protocol came about after MediaWiki 1.4rc1.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition hooks.txt:2198
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:2746
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:1013
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:1971
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition hooks.txt:2805
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
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
An object representing a master or replica DB position in a replicated setup.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:40
Database cluster connection, tracking, load balancing, and transaction manager interface.
$buffer