Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.1

Bug #11580 DB_mysql::tableInfo() bug when using several connections
Submitted: 2007-07-10 19:58 UTC
From: schmidt Assigned: aharvey
Status: Closed Package: DB (version 1.7.12)
PHP Version: 5.2.0 OS: Linux
Roadmaps: 1.7.13    
Subscription  


 [2007-07-10 19:58 UTC] schmidt (Christian Schmidt)
Description: ------------ DB_mysql::tableInfo("string") issues a mysql_query("SELECT ...") without a prior mysql_select_db(). This causes problems when using multiple connections. A fix is to call mysql_select_db() before calling mysql_query() like DB_mysql::simpleQuery() does. Test script: --------------- $db1 = DB::connect('mysql://foo:bar@localhost/db1'); $db2 = DB::connect('mysql://foo:bar@localhost/db2'); var_dump($db1->tableInfo('table1')); Expected result: ---------------- The var_dump() should output an array. It outputs a DB_Error even though the table exists. Uncommenting the second line ($db2 = ...) fixes the problem.

Comments

 [2007-07-11 02:34 UTC] aharvey (Adam Harvey)
Good catch. Will need to check the other drivers as well for similar issues and add a regression test for this.
 [2007-08-03 11:24 UTC] schmidt (Christian Schmidt)
An alternative to using mysql_select_db() is something like this: "SELECT * FROM " . $this->quoteIdentifier($this->_db) . ".$result LIMIT 0"
 [2007-09-21 13:32 UTC] aharvey (Adam Harvey)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. For the record, this ended up affecting both the mysql and mysqli drivers, but no others.