mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
BUGFIX MSSQLDatabaseConfigurationHelper didn't detect existing databases using sqlsrv driver properly
This commit is contained in:
parent
f5ea92fbd8
commit
df785ecbbf
@ -111,11 +111,14 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
|
||||
|
||||
$check = $this->requireDatabaseConnection($databaseConfig);
|
||||
$conn = $check['connection'];
|
||||
if(
|
||||
(function_exists('mssql_select_db') && @mssql_select_db($databaseConfig['database'], $conn))
|
||||
||
|
||||
(function_exists('sqlsrv_select_db') && @sqlsrv_select_db($conn, $databaseConfig['database']))
|
||||
) {
|
||||
|
||||
if(function_exists('mssql_select_db')) {
|
||||
$exists = @mssql_select_db($databaseConfig['database'], $conn);
|
||||
} else {
|
||||
$exists = @sqlsrv_query($conn, "USE \"$databaseConfig[database]\"");
|
||||
}
|
||||
|
||||
if($exists) {
|
||||
$success = true;
|
||||
$alreadyExists = true;
|
||||
} else {
|
||||
@ -129,7 +132,7 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
|
||||
$alreadyExists = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
'success' => $success,
|
||||
'alreadyExists' => $alreadyExists
|
||||
|
Loading…
Reference in New Issue
Block a user