Kadence
Jan 2nd 2008, 5:22 am
Say I have connections to two databases on different servers, $dbh1 and $dbh2. How do I switch the 'current', default connection that mysql_query() uses?
For instance if I do mysql_select_db($dbname, $dbh2), this doesn't seem to make $dbh2 the current connection - I have to explicitly use mysql_query('...', $dbh2) to use the $dbh2 handle. mysql_query('...') without a link identifier seems to assume $dbh1 by default, if $dbh1 was opened more recently. Is there a way to make $dbh2 the default connection without reopening it?
For instance if I do mysql_select_db($dbname, $dbh2), this doesn't seem to make $dbh2 the current connection - I have to explicitly use mysql_query('...', $dbh2) to use the $dbh2 handle. mysql_query('...') without a link identifier seems to assume $dbh1 by default, if $dbh1 was opened more recently. Is there a way to make $dbh2 the default connection without reopening it?