multiple db's classes ptrs? help?

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 8
Joined: Tue Aug 20, 2002 11:57 am

Mon Mar 24, 2003 10:25 pm

I've never done it before, but mysql_query() takes an optional second parameter which is a resource identifier. You could use this param to specify which DB you are connecting to. Eg.

// get link identifiers
$dbh1 = mysql_connect....
$dbh2 = mysql_connect...

// use these link IDs when selecting your DBs
mysql_select_db("DB1", $dbh1);
mysql_select_db("DB2", $dbh2);

// and pass link ID to each query so query uses the correct DB
$result1 = mysql_query("some query", $dbh1);
$result2 = mysql_query("some query", $dbh2);

You said you were using classes so you could set the link ID in your constructor and use it in all of your queries.

Hope this helps!

Post Reply