mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Merge pull request #12 from halkyon/hardcoded_queries
Fixing hardcoded queries that are MySQL specific.
This commit is contained in:
commit
a4d07150ca
@ -185,7 +185,7 @@ class TestSessionEnvironment extends Object {
|
|||||||
DB::connect($databaseConfig);
|
DB::connect($databaseConfig);
|
||||||
} else {
|
} else {
|
||||||
// We've already connected to the database, do a fast check to see what database we're currently using
|
// We've already connected to the database, do a fast check to see what database we're currently using
|
||||||
$db = DB::query("SELECT DATABASE()")->value();
|
$db = DB::getConn()->currentDatabase();
|
||||||
if(isset($state->database) && $db != $state->database) {
|
if(isset($state->database) && $db != $state->database) {
|
||||||
$this->oldDatabaseName = $databaseConfig['database'];
|
$this->oldDatabaseName = $databaseConfig['database'];
|
||||||
$databaseConfig['database'] = $state->database;
|
$databaseConfig['database'] = $state->database;
|
||||||
@ -199,9 +199,7 @@ class TestSessionEnvironment extends Object {
|
|||||||
$dbName = (isset($state->database)) ? $state->database : null;
|
$dbName = (isset($state->database)) ? $state->database : null;
|
||||||
|
|
||||||
if($dbName) {
|
if($dbName) {
|
||||||
$dbExists = (bool)DB::query(
|
$dbExists = DB::getConn()->databaseExists($dbName);
|
||||||
sprintf("SHOW DATABASES LIKE '%s'", Convert::raw2sql($dbName))
|
|
||||||
)->value();
|
|
||||||
} else {
|
} else {
|
||||||
$dbExists = false;
|
$dbExists = false;
|
||||||
}
|
}
|
||||||
@ -410,4 +408,4 @@ class TestSessionEnvironment extends Object {
|
|||||||
$path = Director::getAbsFile($this->getFilePath());
|
$path = Director::getAbsFile($this->getFilePath());
|
||||||
return (file_exists($path)) ? json_decode(file_get_contents($path)) : new stdClass;
|
return (file_exists($path)) ? json_decode(file_get_contents($path)) : new stdClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user