gyro/modules/systemupdate/lib/components/systemupdateconnectionmapper.cls.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Allows switching complete modules to another DB connection 00004 */ 00005 class SystemUpdateConnectionMapper { 00006 static $connections = array(); 00007 00008 /** 00009 * Return all connections, kind of SELECT DISTINCT 00010 * 00011 * @return array 00012 */ 00013 static function get_all_connections() { 00014 $ret = array(); 00015 foreach(self::$connections as $module => $connection) { 00016 $ret[$connection] = $connection; 00017 } 00018 $ret[DB::DEFAULT_CONNECTION] = DB::DEFAULT_CONNECTION; 00019 return $ret; 00020 } 00021 00022 /** 00023 * Return conenction for given module 00024 */ 00025 static function get_module_connection($module) { 00026 return Arr::get_item(self::$connections, $module, DB::DEFAULT_CONNECTION); 00027 } 00028 00029 /** 00030 * Set module connection 00031 */ 00032 static function set_module_connection($module, $connection) { 00033 self::$connections[$module] = $connection; 00034 } 00035 }