MINOR Tidy up of code in MSSQLDatabase::__construct()

This commit is contained in:
Sean Harvey 2010-09-29 04:30:05 +00:00
parent 75b1933ca3
commit 083517d02b

View File

@ -123,7 +123,7 @@ class MSSQLDatabase extends SS_Database {
} else { } else {
user_error("Neither the mssql_connect() nor the sqlsrv_connect() functions are available. Please install the PHP native mssql module, or the Microsoft-provided sqlsrv module.", E_USER_ERROR); user_error("Neither the mssql_connect() nor the sqlsrv_connect() functions are available. Please install the PHP native mssql module, or the Microsoft-provided sqlsrv module.", E_USER_ERROR);
} }
if($this->mssql) { if($this->mssql) {
// Switch to utf8 connection charset // Switch to utf8 connection charset
ini_set('mssql.charset', 'utf8'); ini_set('mssql.charset', 'utf8');
@ -134,26 +134,20 @@ class MSSQLDatabase extends SS_Database {
ini_set('sqlsrv.WarningsReturnAsErrors', 'Off'); ini_set('sqlsrv.WarningsReturnAsErrors', 'Off');
} }
// Windows authentication doesn't require a username and password $options = array(
if(defined('MSSQL_USE_WINDOWS_AUTHENTICATION') && MSSQL_USE_WINDOWS_AUTHENTICATION == true) { 'CharacterSet' => 'UTF-8',
$connectionInfo = array( 'MultipleActiveResultSets' => true
'CharacterSet' => 'UTF-8', );
'MultipleActiveResultSets' => true if(!(defined('MSSQL_USE_WINDOWS_AUTHENTICATION') && MSSQL_USE_WINDOWS_AUTHENTICATION == true)) {
); $options['UID'] = $parameters['username'];
} else { $options['PWD'] = $parameters['password'];
$connectionInfo = array( }
'UID' => $parameters['username'],
'PWD' => $parameters['password'], $this->dbConn = sqlsrv_connect($parameters['server'], $options);
'CharacterSet' => 'UTF-8',
'MultipleActiveResultSets' => true
);
}
$this->dbConn = sqlsrv_connect($parameters['server'], $connectionInfo);
} }
if(!$this->dbConn) { if(!$this->dbConn) {
$this->databaseError("Couldn't connect to MS SQL database"); $this->databaseError('Couldn\'t connect to SQL Server database');
} else { } else {
$this->database = $parameters['database']; $this->database = $parameters['database'];
$this->selectDatabase($this->database); $this->selectDatabase($this->database);