MediaWiki master
IReadableDatabase.php
Go to the documentation of this file.
1<?php
20namespace Wikimedia\Rdbms;
21
22use stdClass;
23use Stringable;
27
28// Very long type annotations :(
29// phpcs:disable Generic.Files.LineLength
30
37interface IReadableDatabase extends Stringable, ISQLPlatform, DbQuoter, IDatabaseFlags {
38
40 public const UNION_ALL = true;
42 public const UNION_DISTINCT = false;
43
51 public function getServerInfo();
52
59 public function tablePrefix( $prefix = null );
60
67 public function dbSchema( $schema = null );
68
72 public function isOpen();
73
81 public function getDomainID();
82
88 public function getType();
89
95 public function lastErrno();
96
102 public function lastError();
103
111 public function getSoftwareLink();
112
118 public function getServerVersion();
119
133 public function close( $fname = __METHOD__ );
134
146
159
190 public function selectField(
191 $tables, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
192 );
193
225 public function selectFieldValues(
226 $tables, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
227 ): array;
228
435 public function select(
436 $tables,
437 $vars,
438 $conds = '',
439 $fname = __METHOD__,
440 $options = [],
441 $join_conds = []
442 );
443
473 public function selectRow(
474 $tables,
475 $vars,
476 $conds,
477 $fname = __METHOD__,
478 $options = [],
479 $join_conds = []
480 );
481
510 public function estimateRowCount(
511 $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
512 ): int;
513
545 public function selectRowCount(
546 $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
547 ): int;
548
561 public function databasesAreIndependent();
562
575 public function selectDomain( $domain );
576
582 public function getDBname();
583
589 public function getServer();
590
597 public function getServerName();
598
604 public function ping();
605
614 public function getLag();
615
629 public function getSessionLagStatus();
630
641 public function encodeBlob( $b );
642
652 public function decodeBlob( $b );
653
668 public function expr( string $field, string $op, $value ): Expression;
669
679 public function andExpr( array $conds ): AndExpressionGroup;
680
690 public function orExpr( array $conds ): OrExpressionGroup;
691
699 public function __toString();
700}
Representing a group of expressions chained via AND.
A composite leaf representing an expression.
Representing a group of expressions chained via OR.
Build SELECT queries with a fluent interface.
A query builder for UNION queries takes SelectQueryBuilder objects.
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)
selectField( $tables, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
selectRow( $tables, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Wrapper to IDatabase::select() that only fetches one row (via LIMIT)
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.
select( $tables, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
lastErrno()
Get the RDBMS-specific error code from the last attempted query statement.
selectFieldValues( $tables, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
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.
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.
getServerName()
Get the readable name for the server.
getServerInfo()
Get a human-readable string describing the current software version.
const UNION_ALL
Parameter to unionQueries() for UNION ALL.
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.
andExpr(array $conds)
See Expression::__construct()
const UNION_DISTINCT
Parameter to unionQueries() for UNION DISTINCT.
orExpr(array $conds)
See Expression::__construct()
__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.