php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67473 Expose close connection feature
Submitted: 2014-06-19 08:35 UTC Modified: 2016-08-29 14:38 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: galinoo at yahoo dot fr Assigned: cmb (profile)
Status: Duplicate Package: PDO related
PHP Version: 5.4.29 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: galinoo at yahoo dot fr
New email:
PHP Version: OS:

 

 [2014-06-19 08:35 UTC] galinoo at yahoo dot fr
Description:
------------
The PDO class actually doesn't expose any method to manually close openened connections (with the PDO constructor).

Please note that the documentation (http://fr2.php.net/manual/en/pdo.connections.php) is not clear about this, and just states setting the variable holding the PDO reference is enough to close the connection ($pdo = NULL).
This sentence is FALSE, and, unfortunately, its real signification is not understandable for PHP newbies, and people would don't really know what it means setting a variable to NULL in PHP (ref count).

In fact, what it means is that references count is used to determine automatically when a connection must be closed: this is an incomplete and unflexible feature.

Many use cases can be found, where one opens a connection, and closes it by hand, when the 'stuff' is done, without waiting for the references count to be 0 or the end of the script. For instance, imagine you're working with a framework able to provide the connection instance, and the instance is holded in many variables, or you're writing a test case, and as you 'setUp' resources, you must also close them during 'tearDown'. You must set all variables to null, but there may be in independent software modules. How to do that?

PDO MUST provide a way to manually close the connection it opens under the hood, for instance a 'close' method in the PDO class shall do the job.

Thanks for your consideration, and your work!
BR


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-29 14:38 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-08-29 14:38 UTC] cmb@php.net
Duplicate of request #62065.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 04:01:27 2024 UTC