php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13232 PEAR messes up with simultaneous connections.
Submitted: 2001-09-10 10:30 UTC Modified: 2001-10-14 07:34 UTC
From: fidian at commnav dot com Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.0.6 OS: Linux 2.2.16
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 + 33 = ?
Subscribe to this entry?

 
 [2001-09-10 10:30 UTC] fidian at commnav dot com
PEAR seems to not be able to handle multiple connections to different databases.  To illustrate, create two tables in different databases (can be on the same server, but different databases within that server).

include("DB.php");
$oneWrapper = new DB();
$oneDB = $oneWrapper->connect("type://user:pass@server/one");
printRes($oneDB->query("select count(*) from table_one"));
$twoWrapper = new DB();
$twoDB = $twoWrapper->connect("type://user:pass@server/two");
printRes($twoDB->query("select count(*) from table_two"));
printRes($oneDB->query("select count(*) from table_one"));
printRes($oneDB->query("select count(*) from table_two"));
function printRes($res) {
   if (DB::isError($res)) {
      echo "Error:  " . DB::errorMessage($res) . "\n";
   } else {
      $data = $res->fetchRow();
      echo "Result: " . $count[0] . "\n";
   }
}


This code will print out

Result:  0
Result:  0
Error:  no such table
Result:  0

Looking back at the code, you will see that $oneDB is now pointing at the $twoDB's database instead of its correct one.

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 24 18:01:23 2021 UTC