microsoft / msphpsql

Microsoft Drivers for PHP for SQL Server
MIT License
1.8k stars 374 forks source link

sqlsrv_errors returns incorrect code #1415

Closed genyslt closed 2 years ago

genyslt commented 2 years ago

PHP version
8.1.11 Microsoft ODBC Driver version
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server] image

CONFIG array( 'Database' => *, 'Uid' => **, 'PWD' => *, 'CharacterSet' => 'UTF-8', 'ReturnDatesAsStrings' => true, 'MultipleActiveResultSets' => true, 'LoginTimeout' => 5 ) Problem description
The sqlsrv_errors(SQLSRV_ERR_ERRORS) returns wrong code Expected behavior and actual behavior
For all situations: FOREIGN KEY constraint, UNIQUE KEY, PRIMARY KEY, TRIGGER and others errors, the DRIVER returns CODE=50000

  1. Situation SQL Server Management Studio RESULT image PHP RESULT image
  2. Situation sqlsrv_errors(SQLSRV_ERR_ERRORS) SQL Server Management Studio RESULT image sqlsrv_errors(SQLSRV_ERR_ERRORS) PHP RESULT image
genyslt commented 2 years ago

Uh, I realy sorry, but i now see, than this query runs in BEGIN TRY CATCH. I think it is false negative