PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #2691

Object Disconnect Closes all connections

Details

Submitted2004-11-04 19:14 UTC
Fromapassos at vernoncollege dot edu
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.9
OSWindows 2003
Roadmaps(Not assigned)

Comments

[2004-11-04 19:14 UTC] apassos at vernoncollege dot edu

Description:
------------
2 Connections to the same database:

a1 = connect to db1
a2 = connect to db1

do some work with a1
disconnect a1

do some work with a2
ERROR: cannot run the query because no database is selected

-----------
Removing the line "disconnect a1" fixes the problem so it can only be understood that when a1 disconnects, all open connections to the same database are closed.

The database in question is MySQL.

Reproduce code:
---------------
<?
error_reporting(E_ALL);
require_once("DB.php");

$dsn= "mysql://someuser:somepasswd@localhost/somedb";
$db =& DB::connect($dsn, array());
if (DB::isError($db)) {
die($db->getMessage());
}
$db2 =& DB::connect($dsn, array());
if (DB::isError($db2)) {
die($db2->getMessage());
}

$res =& $db->query("select * from shell_homepage");
if (DB::isError($res)) {
die($res->getMessage());
}
$db->disconnect();

$res =& $db2->query("select * from shell_homepage");
if (DB::isError($res)) {
die($res->getMessage());
}
$db2->disconnect();
?>

Expected result:
----------------
2 successful queries

(removing the line $db->disconnect fixes this bug)

Actual result:
--------------
Error: Database not selected

[2006-02-03 07:25 UTC] steudel at attraction dot de

The solution you provide is not very helpful. In my opinion the application that manages the db connection pool has to enshure that getting a connection wich DB::connect() returns an open connection and/or that closing one wich <ConnectionObject>->disconnect() not realy closes the connection but returns it to the pool.

One can't be serious to say that people doing GOOD programming have to change their implementation.