[PHP-DEV] PHP 4.0 Bug #7032 Updated: Multiple mysql connections over-write eachother From: Bug Database (php-dev <email protected>)
Date: 10/05/00

ID: 7032
Updated by: sniper
Reported By: bob <email protected>
Status: Closed
Bug Type: MySQL related
Assigned To:
Comments:

Not a bug.

Read these:
http://www.php.net/manual/function.mysql-connect.php
http://sniper/manual/function.mysql-db-query.php

--Jani

Previous Comments:
---------------------------------------------------------------------------

[2000-10-05 04:21:19] bob <email protected>
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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>