MediaWiki  master
DBAccessBase.php
Go to the documentation of this file.
1 <?php
2 
6 
39 abstract class DBAccessBase implements IDBAccessObject {
41  private $lb;
42 
44  protected $dbDomain = false;
45 
49  public function __construct( $dbDomain = false ) {
50  wfDeprecated( __CLASS__, '1.37' );
51 
52  $this->dbDomain = $dbDomain;
53  $this->lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
54  ->getMainLB( $dbDomain );
55  }
56 
69  protected function getConnection( $id, array $groups = [] ) {
70  return $this->getLoadBalancer()->getConnectionRef( $id, $groups, $this->dbDomain );
71  }
72 
83  protected function releaseConnection( IDatabase $db ) {
84  // no-op
85  }
86 
96  protected function getLoadBalancer() {
97  return $this->lb;
98  }
99 }
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:203
DBAccessBase\$dbDomain
string bool $dbDomain
The target wiki's DB domain.
Definition: DBAccessBase.php:44
DBAccessBase\getConnection
getConnection( $id, array $groups=[])
Returns a database connection.
Definition: DBAccessBase.php:69
DBAccessBase\releaseConnection
releaseConnection(IDatabase $db)
Releases a database connection and makes it available for recycling.
Definition: DBAccessBase.php:83
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:57
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Definition: GlobalFunctions.php:997
DBAccessBase
Definition: DBAccessBase.php:39
DBAccessBase\$lb
ILoadBalancer $lb
Definition: DBAccessBase.php:41
DBAccessBase\__construct
__construct( $dbDomain=false)
Definition: DBAccessBase.php:49
DBAccessBase\getLoadBalancer
getLoadBalancer()
Get the database type used for read operations.
Definition: DBAccessBase.php:96
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81