MediaWiki master
IReadableDatabase.php
Go to the documentation of this file.
1<?php
20namespace Wikimedia\Rdbms;
21
22use stdClass;
26
34
36 public const UNION_ALL = true;
38 public const UNION_DISTINCT = false;
39
47 public function getServerInfo();
48
55 public function tablePrefix( $prefix = null );
56
63 public function dbSchema( $schema = null );
64
68 public function isOpen();
69
77 public function getDomainID();
78
84 public function getType();
85
91 public function lastErrno();
92
98 public function lastError();
99
107 public function getSoftwareLink();
108
114 public function getServerVersion();
115
129 public function close( $fname = __METHOD__ );
130
142
155
184 public function selectField(
185 $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
186 );
187
217 public function selectFieldValues(
218 $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
219 ): array;
220
412 public function select(
413 $table,
414 $vars,
415 $conds = '',
416 $fname = __METHOD__,
417 $options = [],
418 $join_conds = []
419 );
420
448 public function selectRow(
449 $table,
450 $vars,
451 $conds,
452 $fname = __METHOD__,
453 $options = [],
454 $join_conds = []
455 );
456
483 public function estimateRowCount(
484 $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
485 ): int;
486
516 public function selectRowCount(
517 $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
518 ): int;
519
532 public function databasesAreIndependent();
533
546 public function selectDomain( $domain );
547
553 public function getDBname();
554
560 public function getServer();
561
568 public function getServerName();
569
577 public function wasDeadlock();
578
584 public function wasReadOnlyError();
585
603 public function primaryPosWait( DBPrimaryPos $pos, $timeout );
604
611 public function getReplicaPos();
612
618 public function ping();
619
628 public function getLag();
629
643 public function getSessionLagStatus();
644
655 public function encodeBlob( $b );
656
666 public function decodeBlob( $b );
667
681 public function expr( string $field, string $op, $value ): Expression;
682
690 public function __toString();
691}
A composite leaf representing an expression.
Build SELECT queries with a fluent interface.
A query builder for UNION queries takes SelectQueryBuilder objects.
An object representing a primary or replica DB position in a replicated setup.
A database connection without write operations.
getSessionLagStatus()
Get a cached estimate of the seconds of replication lag on this database server, using the estimate o...
ping()
Ping the server and try to reconnect if it there is no connection.
close( $fname=__METHOD__)
Close the database connection.
getServerVersion()
A string describing the current software version.
getType()
Get the RDBMS type of the server (e.g.
newSelectQueryBuilder()
Create an empty SelectQueryBuilder which can be used to run queries against this connection.
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
getDBname()
Get the current database name; null if there isn't one.
selectDomain( $domain)
Set the current domain (database, schema, and table prefix)
selectRowCount( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
dbSchema( $schema=null)
Get/set the db schema.
wasDeadlock()
Determines if the last failure was due to a deadlock.
lastErrno()
Get the RDBMS-specific error code from the last attempted query statement.
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
lastError()
Get the RDBMS-specific error description from the last attempted query statement.
tablePrefix( $prefix=null)
Get/set the table prefix.
getServer()
Get the hostname or IP address of the server.
getSoftwareLink()
Returns a wikitext style link to the DB's website (e.g.
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
getLag()
Get the seconds of replication lag on this database server.
estimateRowCount( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Estimate the number of rows in dataset.
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
getServerName()
Get the readable name for the server.
getServerInfo()
Get a human-readable string describing the current software version.
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Wrapper to IDatabase::select() that only fetches one row (via LIMIT)
getDomainID()
Return the currently selected domain ID.
databasesAreIndependent()
Returns true if DBs are assumed to be on potentially different servers.
expr(string $field, string $op, $value)
See Expression::__construct()
newUnionQueryBuilder()
Create an empty UnionQueryBuilder which can be used to run queries against this connection.
getReplicaPos()
Get the replication position of this replica DB.
primaryPosWait(DBPrimaryPos $pos, $timeout)
Wait for the replica server to catch up to a given primary server position.
__toString()
Get a debugging string that mentions the database type, the ID of this instance, and the ID of any un...
Interface for query language.