|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71290 PDO::query() throws both an error and an exception if server has gone away
Submitted: 2016-01-05 17:11 UTC Modified: 2020-02-26 22:38 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: jurchiks101 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: PDO MySQL
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2016-01-05 17:11 UTC] jurchiks101 at gmail dot com
PHP version: PHP 5.6 Revision: r227c898 (January 04 2016, 03:00:00) VC11 x86 Non Thread Safe
I would have tried PHP 7 as well, but your PHP 7 Windows builds have incompatible extension API versions, for which I have already created a bug report. Also, there are no PHP 7 snapshots for Windows.

All I did was download and extract the PHP snapshot, rename php.ini-development to php.ini, enable extension=pdo_mysql.dll, and run `php.exe test.php` with the script from the Gist.

Test script:

Expected result:
There should be no error output since PDO::ATTR_ERRMODE is set to ERRMODE_EXCEPTION.

Actual result:
Both error and exception are output.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-01 15:37 UTC]
-Status: Open +Status: Not a bug
 [2016-02-01 15:37 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

This is a result of the pdo_mysql driver using mysqlnd (MySQL native driver).  pdo_mysql doesn't have control over the warnings thrown by mysqlnd.  

If want to get around this, you'll need to compile pdo_mysql against a different MySQL library.  Your OS indicates Windows, so you'll want to compile against the mysql_config like so:

configure --enable-pdo --with-pdo-mysql=C:\path\to\mysql\bin\mysql_config --with-mysqli=C:\path\to\mysql\bin\mysql_config

I am not very familiar with compiling PHP on Windows, so have a look at the documentation starting here:
 [2016-02-01 15:58 UTC] jurchiks101 at gmail dot com
Yeeeah, I'm not going to compile PHP on Windows, that is waaay too much hassle; not nearly as easy as on Linux.
So I guess it's mysqlnd that should be fixed then.
 [2016-02-01 17:38 UTC]
-Status: Not a bug +Status: Open -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: willfitch
 [2016-02-01 17:38 UTC]
I'm actually going to reopen this.  I'll submit a change that will internally disable/enable warnings from mysqlnd based on the attributes set in PDO.
 [2016-02-01 19:02 UTC] jurchiks101 at gmail dot com
Much appreciated!
 [2016-04-05 09:51 UTC] jurchiks101 at gmail dot com
Any news on this?
 [2017-10-24 03:30 UTC]
-Status: Assigned +Status: Verified -Operating System: Windows 7 x64 +Operating System: * -PHP Version: 5.6Git-2016-01-05 (Git) +PHP Version: * -Assigned To: willfitch +Assigned To:
 [2017-10-24 03:30 UTC]
Given no activity, I'm gonna unassign this one so its open for grabs.
 [2020-02-26 22:38 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-02-26 22:38 UTC]
This issue is already fixed[1] as of PHP 7.4.0.  I don't think
that back-porting the fix to PHP 7.3 makes much sense at this

[1] <;a=commit;h=2856afc70e50b85424b2bd2d6653020679160a0b>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 08:03:34 2021 UTC