Edit report at https://bugs.php.net/bug.php?id=62847&edit=1
ID: 62847
Comment by: rgagnon24 at gmail dot com
Reported by: softwareelves at gmail dot com
Summary: PDO not released (or disconnect) if last query was
error.
Status: Open
Type: Bug
Package: PDO related
Operating System: OSX 10.8
PHP Version: 5.3.16
Block user comment: N
Private report: N
New Comment:
Similar but different stuff happens under PHP5.4.14
It seems the PDOStatement object gets a reference to the PDO it was executed
on, but when the PDOStatement errors or causes a PDOException (depending on the
PDO::ATTR_ERROR_MODE), then the reference to the PDO object is not released,
and you end up with a live database connection, but no way to close or control
it.
Previous Comments:
------------------------------------------------------------------------
[2012-08-17 17:14:21] softwareelves at gmail dot com
Description:
------------
If PDO errors on it's LAST query it will refuse to disconnect from the database
until the end of the script.
Test script:
---------------
<?php
$get_new_pdo = function() {
return new PDO( ... );
};
$pdo1 = $get_new_pdo();
$pdo2 = $get_new_pdo();
$base_line = count( $pdo1->query( "SHOW PROCESSLIST;" )->fetchAll() );
$pdo2->query( "SELECT column FROM non_existent_table;" );
//$pdo2->query( "SELECT 1;" ); //uncommenting this line causes $pdo2 to be
released correctly
$pdo2 = NULL;
$after_unset = count( $pdo1->query( "SHOW PROCESSLIST;" )->fetchAll() );
var_dump( $base_line - $after_unset );
?>
Expected result:
----------------
int(1)
Actual result:
--------------
int(0)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62847&edit=1