From df785ecbbf9f64b6249d4e56493e69e295186553 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 11 Mar 2010 20:09:00 +0000 Subject: [PATCH] BUGFIX MSSQLDatabaseConfigurationHelper didn't detect existing databases using sqlsrv driver properly --- code/MSSQLDatabaseConfigurationHelper.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/MSSQLDatabaseConfigurationHelper.php b/code/MSSQLDatabaseConfigurationHelper.php index 5c5f392..8d53efc 100644 --- a/code/MSSQLDatabaseConfigurationHelper.php +++ b/code/MSSQLDatabaseConfigurationHelper.php @@ -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