00001 <?php
00002
00007 class ForeignDBRepo extends LocalRepo {
00008 # Settings
00009 var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
00010 $tablePrefix, $hasSharedCache;
00011
00012 # Other stuff
00013 var $dbConn;
00014 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
00015 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
00016
00017 function __construct( $info ) {
00018 parent::__construct( $info );
00019 $this->dbType = $info['dbType'];
00020 $this->dbServer = $info['dbServer'];
00021 $this->dbUser = $info['dbUser'];
00022 $this->dbPassword = $info['dbPassword'];
00023 $this->dbName = $info['dbName'];
00024 $this->dbFlags = $info['dbFlags'];
00025 $this->tablePrefix = $info['tablePrefix'];
00026 $this->hasSharedCache = $info['hasSharedCache'];
00027 }
00028
00029 function getMasterDB() {
00030 if ( !isset( $this->dbConn ) ) {
00031 $class = 'Database' . ucfirst( $this->dbType );
00032 $this->dbConn = new $class( $this->dbServer, $this->dbUser,
00033 $this->dbPassword, $this->dbName, false, $this->dbFlags,
00034 $this->tablePrefix );
00035 }
00036 return $this->dbConn;
00037 }
00038
00039 function getSlaveDB() {
00040 return $this->getMasterDB();
00041 }
00042
00043 function hasSharedCache() {
00044 return $this->hasSharedCache;
00045 }
00046
00052 function getSharedCacheKey( ) {
00053 if ( $this->hasSharedCache() ) {
00054 $args = func_get_args();
00055 array_unshift( $args, $this->dbName, $this->tablePrefix );
00056 return call_user_func_array( 'wfForeignMemcKey', $args );
00057 } else {
00058 return false;
00059 }
00060 }
00061
00062 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
00063 throw new MWException( get_class($this) . ': write operations are not supported' );
00064 }
00065 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
00066 throw new MWException( get_class($this) . ': write operations are not supported' );
00067 }
00068 function deleteBatch( $fileMap ) {
00069 throw new MWException( get_class($this) . ': write operations are not supported' );
00070 }
00071 }