}
/**
- * @return DatabaseBase
+ * @return IDatabase
*/
function getMasterDB() {
if ( !isset( $this->dbConn ) ) {
- $this->dbConn = DatabaseBase::factory( $this->dbType,
+ $func = $this->getDBFactory();
+ $this->dbConn = $func( DB_MASTER );
+ }
+
+ return $this->dbConn;
+ }
+
+ /**
+ * @return IDatabase
+ */
+ function getSlaveDB() {
+ return $this->getMasterDB();
+ }
+
+ /**
+ * @return Closure
+ */
+ protected function getDBFactory() {
+ return function( $index ) {
+ return DatabaseBase::factory( $this->dbType,
array(
'host' => $this->dbServer,
'user' => $this->dbUser,
'foreign' => true,
)
);
- }
-
- return $this->dbConn;
- }
-
- /**
- * @return DatabaseBase
- */
- function getSlaveDB() {
- return $this->getMasterDB();
+ };
}
/**