1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-01 11:50:15 +02:00

SqlsrvDriver: workaround for "Driver's SQLSetConnectAttr failed on ODBC <=13" bug

This commit is contained in:
David Grudl
2021-03-10 16:39:19 +01:00
parent 0d2f643795
commit 49f2bf867f

View File

@@ -63,11 +63,13 @@ class SqlsrvDriver implements Dibi\Driver
$options['UID'] = (string) $options['UID']; $options['UID'] = (string) $options['UID'];
$options['Database'] = (string) $options['Database']; $options['Database'] = (string) $options['Database'];
sqlsrv_configure('WarningsReturnAsErrors', 0);
$this->connection = sqlsrv_connect($config['host'], $options); $this->connection = sqlsrv_connect($config['host'], $options);
sqlsrv_configure('WarningsReturnAsErrors', 1);
} }
if (!is_resource($this->connection)) { if (!is_resource($this->connection)) {
$info = sqlsrv_errors(); $info = sqlsrv_errors(SQLSRV_ERR_ERRORS);
throw new Dibi\DriverException($info[0]['message'], $info[0]['code']); throw new Dibi\DriverException($info[0]['message'], $info[0]['code']);
} }
$this->version = sqlsrv_server_info($this->connection)['SQLServerVersion']; $this->version = sqlsrv_server_info($this->connection)['SQLServerVersion'];