From: Operating system: Any PHP version: 5.3.13 Package: PDO related Bug Type: Bug Bug description:PDO should have a disconnect method
Description: ------------ Currently the advertised way of having pdo disconnect from the database is to assign "null" to the pdo handle. This may work acceptably well in tutorials, however in real life this approach is impractical. When testing with, say, phpunit (dbunit), the setup code creates a connection and gives a pdo instance to phpunit. What phpunit subsequently does with that instance and in particular how many times the pdo variable is copied and assigned to cyclical and/or permanently referenced structures, is not something that connection management code can control. Example code from phpbb: https://github.com/phpbb/phpbb3/blob/develop/tests/test_framework/phpbb_database_test_connection_manager.php#L38 - connect function is called by phpunit. Currently in phpbb tests the database connections are not closed by pdo. This requires for example postgresql and oracle databases to be configured to allow more concurrent database connections than we have tests in the test suite. You might be tempted to say that it's phpunit's fault for not closing database connections, or there is a bug in phpbb test code which results in connections not being closed. Consider how such a bug might be found. If I close a connection when I think it should no longer be used, and subsequently it is used, I will receive an error pointing to the responsible party. How would you diagnose the same bug if there is no way to close a database connection explicitly? Not to mention that disconnecting from the database is a core operation of any sane db api. There is no need to change existing behavior of connection closing on finalization. The disconnect method should be in addition to existing functionality. Expected result: ---------------- PDO should provide a method on connections to disconnect from the database. -- Edit bug report at https://bugs.php.net/bug.php?id=62065&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62065&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62065&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62065&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62065&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62065&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62065&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62065&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62065&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62065&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62065&r=support Expected behavior: https://bugs.php.net/fix.php?id=62065&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62065&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62065&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62065&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62065&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62065&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62065&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62065&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62065&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62065&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62065&r=mysqlcfg