MediaWiki REL1_37
Wikimedia\Rdbms\ConnectionManager Class Reference

Database connection manager. More...

Inheritance diagram for Wikimedia\Rdbms\ConnectionManager:
Collaboration diagram for Wikimedia\Rdbms\ConnectionManager:

Public Member Functions

 __construct (ILoadBalancer $loadBalancer, $domain=false, array $groups=[])
 
 getLazyReadConnectionRef (array $groups=null)
 Returns a lazy-connecting database connection ref for reading.
 
 getReadConnection (?array $groups=null, int $flags=0)
 Returns a database connection for reading.
 
 getReadConnectionRef (array $groups=null)
 Returns a database connection ref for reading.
 
 getWriteConnection (int $flags=0)
 Returns a connection to the primary DB, for updating.
 
 getWriteConnectionRef ()
 Returns a connection ref to the primary DB, for updating.
 
 releaseConnection (IDatabase $db)
 

Private Member Functions

 getConnection ( $i, ?array $groups=null, int $flags=0)
 
 getConnectionRef ( $i, array $groups=null)
 
 getLazyConnectionRef ( $i, array $groups=null)
 

Private Attributes

string false $domain
 The symbolic name of the target database, or false for the local wiki's database.
 
string[] $groups = []
 
ILoadBalancer $loadBalancer
 

Detailed Description

Database connection manager.

This manages access to primary and replica databases.

Since
1.29
Author
Addshore

Definition at line 35 of file ConnectionManager.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\ConnectionManager::__construct ( ILoadBalancer  $loadBalancer,
  $domain = false,
array  $groups = [] 
)
Parameters
ILoadBalancer$loadBalancer
string | bool$domainOptional logical DB name, defaults to current wiki. This follows the convention for database names used by $loadBalancer.
string[]$groupssee LoadBalancer::getConnection
Exceptions
InvalidArgumentException

Definition at line 62 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$domain, Wikimedia\Rdbms\ConnectionManager\$groups, and Wikimedia\Rdbms\ConnectionManager\$loadBalancer.

Member Function Documentation

◆ getConnection()

Wikimedia\Rdbms\ConnectionManager::getConnection (   $i,
?array  $groups = null,
int  $flags = 0 
)
private
Parameters
int$i
string[] | null$groups
int$flags
Returns
IDatabase

Definition at line 79 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

Referenced by Wikimedia\Rdbms\ConnectionManager\getReadConnection(), and Wikimedia\Rdbms\ConnectionManager\getWriteConnection().

◆ getConnectionRef()

Wikimedia\Rdbms\ConnectionManager::getConnectionRef (   $i,
array  $groups = null 
)
private
Parameters
int$i
string[] | null$groups
Returns
DBConnRef

Definition at line 90 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

Referenced by Wikimedia\Rdbms\ConnectionManager\getReadConnectionRef(), and Wikimedia\Rdbms\ConnectionManager\getWriteConnectionRef().

◆ getLazyConnectionRef()

Wikimedia\Rdbms\ConnectionManager::getLazyConnectionRef (   $i,
array  $groups = null 
)
private
Parameters
int$i
string[] | null$groups
Returns
DBConnRef

Definition at line 101 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

Referenced by Wikimedia\Rdbms\ConnectionManager\getLazyReadConnectionRef().

◆ getLazyReadConnectionRef()

Wikimedia\Rdbms\ConnectionManager::getLazyReadConnectionRef ( array  $groups = null)

Returns a lazy-connecting database connection ref for reading.

Since
1.37
Parameters
string[] | null$groups
Returns
DBConnRef

Definition at line 181 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups, DB_REPLICA, and Wikimedia\Rdbms\ConnectionManager\getLazyConnectionRef().

◆ getReadConnection()

Wikimedia\Rdbms\ConnectionManager::getReadConnection ( ?array  $groups = null,
int  $flags = 0 
)

Returns a database connection for reading.

The connection should later be released by calling releaseConnection().

Since
1.29
1.37 Added optional $flags parameter
Parameters
string[] | null$groups
int$flags
Returns
IDatabase

Reimplemented in Wikimedia\Rdbms\SessionConsistentConnectionManager.

Definition at line 133 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups, DB_REPLICA, and Wikimedia\Rdbms\ConnectionManager\getConnection().

◆ getReadConnectionRef()

Wikimedia\Rdbms\ConnectionManager::getReadConnectionRef ( array  $groups = null)

Returns a database connection ref for reading.

Since
1.29
Parameters
string[] | null$groups
Returns
DBConnRef

Reimplemented in Wikimedia\Rdbms\SessionConsistentConnectionManager.

Definition at line 167 of file ConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups, DB_REPLICA, and Wikimedia\Rdbms\ConnectionManager\getConnectionRef().

◆ getWriteConnection()

Wikimedia\Rdbms\ConnectionManager::getWriteConnection ( int  $flags = 0)

Returns a connection to the primary DB, for updating.

The connection should later be released by calling releaseConnection().

Since
1.29
1.37 Added optional $flags parameter
Parameters
int$flags
Returns
IDatabase

Reimplemented in Wikimedia\Rdbms\SessionConsistentConnectionManager.

Definition at line 117 of file ConnectionManager.php.

References DB_PRIMARY, and Wikimedia\Rdbms\ConnectionManager\getConnection().

◆ getWriteConnectionRef()

Wikimedia\Rdbms\ConnectionManager::getWriteConnectionRef ( )

Returns a connection ref to the primary DB, for updating.

Since
1.29
Returns
DBConnRef

Reimplemented in Wikimedia\Rdbms\SessionConsistentConnectionManager.

Definition at line 154 of file ConnectionManager.php.

References DB_PRIMARY, and Wikimedia\Rdbms\ConnectionManager\getConnectionRef().

◆ releaseConnection()

Wikimedia\Rdbms\ConnectionManager::releaseConnection ( IDatabase  $db)
Since
1.29
Parameters
IDatabase$db

Definition at line 143 of file ConnectionManager.php.

Member Data Documentation

◆ $domain

string false Wikimedia\Rdbms\ConnectionManager::$domain
private

The symbolic name of the target database, or false for the local wiki's database.

Definition at line 47 of file ConnectionManager.php.

Referenced by Wikimedia\Rdbms\ConnectionManager\__construct().

◆ $groups

◆ $loadBalancer

ILoadBalancer Wikimedia\Rdbms\ConnectionManager::$loadBalancer
private

Definition at line 40 of file ConnectionManager.php.

Referenced by Wikimedia\Rdbms\ConnectionManager\__construct().


The documentation for this class was generated from the following file: