PHP 4.0 Bug #7032: Multiple mysql connections over-write eachother

From: Date: Thu, 05 Oct 2000 08:21:19 +0000
Subject: PHP 4.0 Bug #7032: Multiple mysql connections over-write eachother
Groups: php.dev 
Request: Send a blank email to php-dev+get-34258@lists.php.net to get a copy of this message
From: bob@ark.org Operating system: Unix PHP version: 4.0.2 PHP Bug Type: MySQL related Bug description: Multiple mysql connections over-write eachother Assume you have 2 database in one mysql server: Database1 (contains table: table1) Database2 (contains table: table2) Try this: ----------------------- $conn_id1 = mysql_connect("localhost", "root", ""); $conn_id2 = mysql_connect("localhost", "root", ""); mysql_select_db("Database1", $conn_id1); mysql_select_db("Database2", $conn_id2); mysql_query("select * from table1", $conn_id1); mysql_query("select * from table2", $conn_id2); ----------------- the first query will fail, b/c the 'select_db' for conn_id1 was overwritten in the 'select_db' for conn_id2: it is looking for table1 in Database2. This hold true even inside objects, so it is difficult to create an object that accesses the database and use it in a script that accesses a different database.

« previous php.dev (#34258) next »