MediaWiki  REL1_22
ForeignDBViaLBRepo.php
Go to the documentation of this file.
00001 <?php
00029 class ForeignDBViaLBRepo extends LocalRepo {
00030     var $wiki, $dbName, $tablePrefix;
00031     var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
00032     var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
00033 
00037     function __construct( $info ) {
00038         parent::__construct( $info );
00039         $this->wiki = $info['wiki'];
00040         list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
00041         $this->hasSharedCache = $info['hasSharedCache'];
00042     }
00043 
00047     function getMasterDB() {
00048         return wfGetDB( DB_MASTER, array(), $this->wiki );
00049     }
00050 
00054     function getSlaveDB() {
00055         return wfGetDB( DB_SLAVE, array(), $this->wiki );
00056     }
00057 
00058     function hasSharedCache() {
00059         return $this->hasSharedCache;
00060     }
00061 
00068     function getSharedCacheKey( /*...*/ ) {
00069         if ( $this->hasSharedCache() ) {
00070             $args = func_get_args();
00071             array_unshift( $args, $this->wiki );
00072             return implode( ':', $args );
00073         } else {
00074             return false;
00075         }
00076     }
00077 
00078     protected function assertWritableRepo() {
00079         throw new MWException( get_class( $this ) . ': write operations are not supported.' );
00080     }
00081 }