Hi:
Instead of spending the next 3 days investigating, I thought I'd ask for some help for a change.
I'm trying to figure out how to do multiple MySQL connects. I keep having trouble, but probably somebody knows how to do this.
I want to take data from my MySQL db on my own hard drive (localhost), and transfer it to one or more databases on my internet servers.
(I can't just do a dump and upload because auto_sequencing of foreign keyed records gets me in trouble. For example, person (record 10) on my development db creates one or more records (say records 101 and 102) and one or more address records (say 202, 203, and 204). On the working internet dbs, the record numbers for those foreign records may already be used and totally different when I upload them. I need to be able to figure out the foreign keys for all these records as I upload all the data).
What it boils down to is: it's FAIRLY easy if I can just get multiple connections going at once. Don't know if this can be done, however.
Can I do something like:
function connect1(){
$connect1=mysql_connect('localhost', 'localuser', 'localpass');
$db1=mysql_select_db('localdb');
}
function connect2(){
$connect2=mysql_connect('server.com', 'serveruser, 'serverpass');
$db2=mysql_select_db('serverdb');
}
function connect3(){
$connect3=mysql_connect('server.com', 'serveruser, 'serverpass');
$db3=mysql_select_db('Yetanotherdb');
}
then do something like:
connect1();
$result1=mysql_query("SELECT 'some local info' from sometable");
$row=mysql_fetch_array($result1);
$somedata=$row[0];
connect2();
$result=mysql_query("UPDATE sometable SET somecolumn='$somedata'");
and thereby transfer data from db1 to db2?
The connect string I use on my internet servers includes "localhost" as one of the parameters. Hadn't investigated this until now, as this works fine as currently operating, but my guess is I need to use either a .com type name or a IP address. Any pointers?
All info welcome.
Thanks.
Nemo