BUGFIX MSSQLDatabaseConfigurationHelper didn't detect existing databases using sqlsrv driver properly

This commit is contained in:
Sean Harvey 2010-03-11 20:09:00 +00:00
parent f5ea92fbd8
commit df785ecbbf

View File

@ -111,11 +111,14 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
$check = $this->requireDatabaseConnection($databaseConfig); $check = $this->requireDatabaseConnection($databaseConfig);
$conn = $check['connection']; $conn = $check['connection'];
if(
(function_exists('mssql_select_db') && @mssql_select_db($databaseConfig['database'], $conn)) if(function_exists('mssql_select_db')) {
|| $exists = @mssql_select_db($databaseConfig['database'], $conn);
(function_exists('sqlsrv_select_db') && @sqlsrv_select_db($conn, $databaseConfig['database'])) } else {
) { $exists = @sqlsrv_query($conn, "USE \"$databaseConfig[database]\"");
}
if($exists) {
$success = true; $success = true;
$alreadyExists = true; $alreadyExists = true;
} else { } else {
@ -129,7 +132,7 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
$alreadyExists = false; $alreadyExists = false;
} }
} }
return array( return array(
'success' => $success, 'success' => $success,
'alreadyExists' => $alreadyExists 'alreadyExists' => $alreadyExists