php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jurchiks101 at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-05 17:11 UTC] jurchiks101 at gmail dot com
Description:
------------
PHP version: http://windows.php.net/snapshots/ 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:
---------------
https://gist.github.com/jurchiks/c8fff1e5ec8c97005425

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.

Patches

Pull Requests

History

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

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: https://wiki.php.net/internals/windows/stepbystepbuild.
 [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] willfitch@php.net
-Status: Not a bug +Status: Open -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: willfitch
 [2016-02-01 17:38 UTC] willfitch@php.net
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] kalle@php.net
-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] kalle@php.net
Given no activity, I'm gonna unassign this one so its open for grabs.
 [2020-02-26 22:38 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-02-26 22:38 UTC] cmb@php.net
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
point.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=2856afc70e50b85424b2bd2d6653020679160a0b>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Feb 09 02:01:29 2025 UTC