mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-01 05:39:10 +02:00
Merge pull request #878 from chillu/pulls/alternative-db-session
BUG Using Session::set() for DB::set_alternative_database_name()
This commit is contained in:
commit
9eb4af37bf
@ -65,14 +65,14 @@ class DB {
|
|||||||
* Set it to null to revert to the main database.
|
* Set it to null to revert to the main database.
|
||||||
*/
|
*/
|
||||||
public static function set_alternative_database_name($dbname) {
|
public static function set_alternative_database_name($dbname) {
|
||||||
$_SESSION["alternativeDatabaseName"] = $dbname;
|
Session::set("alternativeDatabaseName", $dbname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the database in use
|
* Get the name of the database in use
|
||||||
*/
|
*/
|
||||||
public static function get_alternative_database_name() {
|
public static function get_alternative_database_name() {
|
||||||
return $_SESSION["alternativeDatabaseName"];
|
return Session::get("alternativeDatabaseName");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,8 +84,8 @@ class DB {
|
|||||||
*/
|
*/
|
||||||
public static function connect($databaseConfig) {
|
public static function connect($databaseConfig) {
|
||||||
// This is used by TestRunner::startsession() to test up a test session using an alt
|
// This is used by TestRunner::startsession() to test up a test session using an alt
|
||||||
if(isset($_SESSION) && !empty($_SESSION['alternativeDatabaseName'])) {
|
if($name = Session::get('alternativeDatabaseName')) {
|
||||||
$databaseConfig['database'] = $_SESSION['alternativeDatabaseName'];
|
$databaseConfig['database'] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
|
if(!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
|
||||||
|
Loading…
Reference in New Issue
Block a user