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
434 public function select(
435 $tables,
436 $vars,
437 $conds = '',
438 $fname = __METHOD__,
439 $options = [],
440 $join_conds = []
441 );
442
472 public function selectRow(
473 $tables,
474 $vars,
475 $conds,
476 $fname = __METHOD__,
477 $options = [],
478 $join_conds = []
479 );
480
508 public function estimateRowCount(
509 $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
510 ): int;
511
542 public function selectRowCount(
543 $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
544 ): int;
545
558 public function databasesAreIndependent();
559
572 public function selectDomain( $domain );
573
579 public function getDBname();
580
586 public function getServer();
587
594 public function getServerName();
595
601 public function ping();
602
611 public function getLag();
612
626 public function getSessionLagStatus();
627
638 public function encodeBlob( $b );
639
649 public function decodeBlob( $b );
650
665 public function expr( string $field, string $op, $value ): Expression;
666
676 public function andExpr( array $conds ): AndExpressionGroup;
677
687 public function orExpr( array $conds ): OrExpressionGroup;
688
696 public function __toString();
697}
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.