What is the difference between the Connect and NConnect in an ADODB Connection object?
I have found out the hard way....
Please examine the code below:
$db1 = NewADOConnection("mysql");
$db2 = NewADOConnection("mysql);
$db1->Connect("localhost", "user", "password", "db1");
$db2->Connect("localhost", "user", "password", "db2");
$rs = $db1->Execute("select * from table1") or die($db1->ErrorMsg());
If table1 does not exist in db2, the code above will produce error, complaining that table1 does not exist in db2.
Wow, but I am executing the command in db1!!!
Apparently, the adodb, in this case, with same host and user, will reuse the connection.
So, in this case, you have to force it open new connection...
Use NConnect, instead of Connect or PConnect.
For further research, RTFM at the adodb documentation.
1 comment:
thank you. I was connecting to multiple databases in the same page and experience similar problems
Post a Comment