Adding a ConenctionManager::drop() method useful for testing and other dynamic tasks

This commit is contained in:
Jose Lorenzo Rodriguez 2011-04-16 22:57:05 -04:30
parent c80a51a163
commit f14a295a3e
2 changed files with 39 additions and 2 deletions

View file

@ -201,8 +201,7 @@ class ConnectionManager {
}
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) {
$null = null;
return $null;
return null;
}
self::$config->{$name} = $config;
self::$_connectionsEnum[$name] = self::_connectionData($config);
@ -210,6 +209,24 @@ class ConnectionManager {
return $return;
}
/**
* Removes a connection configuration at runtime given its name
*
* @param string $name the connection name as it was created
* @return boolean success if connection was removed, false if it does not exist
*/
public static function drop($name) {
if (empty(self::$_init)) {
self::init();
}
if (!isset(self::$config->{$name})) {
return false;
}
unset(self::$_connectionsEnum[$name], self::$_dataSources[$name], self::$config->{$name});
return true;
}
/**
* Gets a list of class and file names associated with the user-defined DataSource connections
*