PHP 4.0 Bug #7032 Updated: Multiple mysql connections over-write eachother
| From: | Bug Database | Date: | Fri, 06 Oct 2000 01:18:45 +0000 |
| Subject: | PHP 4.0 Bug #7032 Updated: Multiple mysql connections over-write eachother | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-34311@lists.php.net to get a copy of this message | ||
ID: 7032
User Update by: bob@ark.org
Status: Closed
Bug Type: MySQL related
Description: Multiple mysql connections over-write eachother
oops.. I am idiot.. sorry
Previous Comments:
---------------------------------------------------------------------------
[2000-10-05 13:17:06] sniper@php.net
Not a bug.
Read these:
http://www.php.net/manual/function.mysql-connect.php
http://sniper/manual/function.mysql-db-query.php
--Jani
---------------------------------------------------------------------------
[2000-10-05 04:21:19] bob@ark.org
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.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7032