X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabaseMssql.php;h=61367f599098fe5584a5395c64597e2104c71b3d;hb=c69bf3bc87bacc84da42f95781e950e4bc9d48d1;hp=fed6f146167ac4289a9a59f50ab88287a39e2c32;hpb=695d7c28fe7036e9988ce92908185ebc41238296;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabaseMssql.php b/includes/libs/rdbms/database/DatabaseMssql.php index fed6f14616..61367f5990 100644 --- a/includes/libs/rdbms/database/DatabaseMssql.php +++ b/includes/libs/rdbms/database/DatabaseMssql.php @@ -77,16 +77,7 @@ class DatabaseMssql extends Database { parent::__construct( $params ); } - /** - * Usually aborts on failure - * @param string $server - * @param string $user - * @param string $password - * @param string $dbName - * @throws DBConnectionError - * @return bool|resource|null - */ - public function open( $server, $user, $password, $dbName ) { + protected function open( $server, $user, $password, $dbName, $schema, $tablePrefix ) { # Test for driver support, to avoid suppressed fatal error if ( !function_exists( 'sqlsrv_connect' ) ) { throw new DBConnectionError( @@ -105,11 +96,10 @@ class DatabaseMssql extends Database { $this->server = $server; $this->user = $user; $this->password = $password; - $this->dbName = $dbName; $connectionInfo = []; - if ( $dbName ) { + if ( $dbName != '' ) { $connectionInfo['Database'] = $dbName; } @@ -129,8 +119,13 @@ class DatabaseMssql extends Database { } $this->opened = true; + $this->currentDomain = new DatabaseDomain( + ( $dbName != '' ) ? $dbName : null, + null, + $tablePrefix + ); - return $this->conn; + return (bool)$this->conn; } /** @@ -243,7 +238,7 @@ class DatabaseMssql extends Database { } /** - * @param MssqlResultWrapper $res + * @param IResultWrapper $res * @return stdClass */ public function fetchObject( $res ) { @@ -252,7 +247,7 @@ class DatabaseMssql extends Database { } /** - * @param MssqlResultWrapper $res + * @param IResultWrapper $res * @return array */ public function fetchRow( $res ) { @@ -1015,7 +1010,7 @@ class DatabaseMssql extends Database { } if ( $schema === false ) { - $schema = $this->schema; + $schema = $this->dbSchema(); } $res = $this->query( "SELECT 1 FROM INFORMATION_SCHEMA.TABLES @@ -1176,18 +1171,13 @@ class DatabaseMssql extends Database { $s ); } - /** - * @param string $db - * @return bool - */ - public function selectDB( $db ) { - try { - $this->dbName = $db; - $this->query( "USE $db" ); - return true; - } catch ( Exception $e ) { - return false; - } + protected function doSelectDomain( DatabaseDomain $domain ) { + $encDatabase = $this->addIdentifierQuotes( $domain->getDatabase() ); + $this->query( "USE $encDatabase" ); + // Update that domain fields on success (no exception thrown) + $this->currentDomain = $domain; + + return true; } /** @@ -1315,8 +1305,8 @@ class DatabaseMssql extends Database { private function populateColumnCaches() { $res = $this->select( 'INFORMATION_SCHEMA.COLUMNS', '*', [ - 'TABLE_CATALOG' => $this->dbName, - 'TABLE_SCHEMA' => $this->schema, + 'TABLE_CATALOG' => $this->getDBname(), + 'TABLE_SCHEMA' => $this->dbSchema(), 'DATA_TYPE' => [ 'varbinary', 'binary', 'image', 'bit' ] ] );