RE: [PHP] two different MySQL connections without always select_db?
| From: | Nick Richardson | Date: | Sat, 09 Mar 2002 07:01:00 +0000 |
| Subject: | RE: [PHP] two different MySQL connections without always select_db? | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-17589@lists.php.net to get a copy of this message | ||
i dont know if this will work, but you can try selecting them in the
query... i.e.:
select * from database.table
I am by no means a guru on sql queries, but it may work.
-----Original Message-----
From: PHP freak [mailto:php@hitmedia.com]
Sent: Friday, March 08, 2002 8:39 PM
To: php-general@lists.php.net; php-db@lists.php.net
Subject: [PHP] two different MySQL connections without always select_db?
How would you keep two different MySQL connections to two different MySQL
databases (on two different MySQL servers) up and available with two
different pointers (id), and not need to always do "select_db()" to switch
between them?
I thought that if I did this:
----------- php: -------------
$aaa_link = mysql_pconnect("localhost", "u", "p");
mysql_select_db("apples", $aaa_link);
$zzz_link = mysql_pconnect("remotehost", "u", "p");
mysql_select_db("zebras", $zzz_link);
------------------------------
... that I'd be able to access both pretty easily. Like this:
----------- php: -------------
$aaa_result = mysql_query("select * from apples", $aaa_link);
$orchard = mysql_fetch_assoc($aaa_result);
$zzz_result = mysql_query("select * from zebras", $zzz_link);
$zoo = mysql_fetch_assoc($zzz_result);
$aaa_result = mysql_query("update apples set something='" .
$zoo['zebrafur']
. "'", $aaa_link);
------------------------------
But it seems to tell me that $zzz_result is not a valid resource - unless I
do the select_db thing inbetween the two commands.
Is there anyone doing this successfully? Back-n-forth between two
databases?
Thanks for any help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php