php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77572 Errors not shown properly
Submitted: 2019-02-05 21:29 UTC Modified: 2021-04-21 11:28 UTC
Votes:3
Avg. Score:3.0 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: ja at agares dot info Assigned:
Status: Verified Package: PDO ODBC
PHP Version: 7.2.14 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
7 + 2 = ?
Subscribe to this entry?

 
 [2019-02-05 21:29 UTC] ja at agares dot info
Description:
------------
When the driver emits a message that's not an error (like in my example). The error after that will show the previous message instead of the actual error.
I reported this as a bug in the SQLSRV repo (https://github.com/Microsoft/msphpsql/issues/924). And the maintainers suggested that it's most likely an issue within PDO itself.

Test script:
---------------
<?php
	$pdo = new \PDO('sqlsrv:Server=localhost;Database=test');
	$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
	$statement = $pdo->prepare('SET NOCOUNT ON; USE test2; SELECT 1/0 AS col1');
	$statement->execute();
	
	var_dump($statement->fetchColumn());


Expected result:
----------------
An error about division by zero

Actual result:
--------------
PHP Fatal error:  Uncaught PDOException: SQLSTATE[01000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed database context to 'test2'.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-21 11:28 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: PDO Core +Package: PDO ODBC
 [2021-04-21 11:28 UTC] cmb@php.net
I can confirm this issue, but that isn't a PDO Core issue, but
rather specific to PDO ODBC.  Bug #78196 is closely related.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC