MSSQL sqlsrv_errors not working
janfejtek opened this issue · comments
Version: 4.2.2
ODBC: ODBC Driver 17 for SQL Server (on windows)
Bug Description
Argument 1 passed to Dibi\Exception::__construct() must be of the type string, null given, called in D:\www_root_vip\vendor\dibi\dibi\src\Dibi\Drivers\SqlsrvDriver.php on line 73
and Notice: Trying to access array offset on value of type null in D:\www_root_vip\vendor\dibi\dibi\src\Dibi\Drivers\SqlsrvDriver.php:73
I think it is caused by this call
dibi/src/Dibi/Drivers/SqlsrvDriver.php
Line 66 in 15a9c98
because sqlsrv_errors
Returns error and warning information about the last SQLSRV operation performed
and that is sqlsrv_configure
call https://github.com/microsoft/msphpsql/blob/00de4738ce214666292a69f7786ff7f2c083f86e/source/sqlsrv/util.cpp#L571
Steps To Reproduce
For example incorrect password in dibi configuration or any issue with initial connection
Expected Behavior
Show correct error message
Possible Solution
Maybe move sqlsrv_configure('WarningsReturnAsErrors', 1)
after exception throw block? I don't know what is the reason for workaround in mentioned commit.
Can you please send a PR? I don't use SQL Server.