2013-04-09 22:13:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Database factory class, this will determine whether to use the main database
|
|
|
|
* or an external database defined in configuration file
|
|
|
|
*/
|
|
|
|
class MWEchoDbFactory {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrapper function for wfGetDB
|
|
|
|
*
|
|
|
|
* @param $db int Index of the connection to get
|
|
|
|
* @param $groups mixed Query groups.
|
2013-10-08 20:48:54 +00:00
|
|
|
* @param $wiki string|bool The wiki ID, or false for the current wiki
|
2013-04-09 22:13:39 +00:00
|
|
|
* @return DatabaseBase
|
|
|
|
*/
|
|
|
|
public static function getDB( $db, $groups = array(), $wiki = false ) {
|
2013-04-18 21:33:38 +00:00
|
|
|
global $wgEchoCluster;
|
2013-04-09 22:13:39 +00:00
|
|
|
|
2013-04-18 21:33:38 +00:00
|
|
|
// Use the external db defined for Echo
|
|
|
|
if ( $wgEchoCluster ) {
|
|
|
|
$lb = wfGetLBFactory()->getExternalLB( $wgEchoCluster, $wiki );
|
|
|
|
} else {
|
|
|
|
$lb = wfGetLB( $wiki );
|
2013-04-09 22:13:39 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 21:33:38 +00:00
|
|
|
return $lb->getConnection( $db, $groups, $wiki );
|
|
|
|
|
2013-04-09 22:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|