Skip to content

MSSQL sqlsrv_errors not working #390

@janfejtek

Description

@janfejtek

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

sqlsrv_configure('WarningsReturnAsErrors', 1);
added in 40ad77c

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions