PEAR is archived and read-only

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

Home » Database » MDB2 » Bug #10210

2 connections to the same server but w/ different DBs

Details

Submitted2007-02-27 18:41 UTC
Fromerudd at netfor dot com
Assignedquipo
StatusDuplicate
PackageMDB2
PHP Version5.1.6
OSFedora Core 6 x86_64
Roadmaps(Not assigned)

Comments

[2007-02-27 18:41 UTC] erudd at netfor dot com

Description:
------------
If I make 2 new MDB2 objects w/ a connection to the same database server but with different default databases, BOTH MDB2 objects will have their selected DB set to the "second" connection.

under the OLD DB class layer this did not occur as the old DB layer would force a mysql_select_db for every query. where as MDB2 does not, only if you "pass" a different DB name in as a parameter to the query function.

The reason this occurs is that mysql_connect will do it's own *connection caching* and return the same link back for the second connection w/ the same host, username, and password (unless the newlink parameter is set to true).

I was hoping to be able to switch to MDB2, but this kinda puts a blocker on that.

Test script:
---------------
$db1 =& MDB2::connect("mysql://bob:test@localhost/database1");

$db2 =& MDB2::connect("mysql://bob:test@localhost/database2");
$db2->loadModule('extended');

$ret = $db1->getAll("SHOW TABLES");
var_dump($ret);

Expected result:
----------------
should show the tables from database1

Actual result:
--------------
shows the tables from database2