Let's say, I have two databases, on the same host (however, two different usernames). And now I'd like to create one mysql query doing something on both databases. Now, I have no idea which connection handle to use, for example:
Code: Select all
//connecting with db1:
$conn1=mysql_connect("localhost","db1_user","db1_pass") or die(mysql_error());
mysql_select_db("db1",$conn1)or die(mysql_error());
//connecting with db2:
$conn2=mysql_connect("localhost","db2_user","db2_pass") or die(mysql_error());
mysql_select_db("db2",$conn2)or die(mysql_error());
//now I want to create a table in db1 LIKE table in db2, which connection should I use, $conn1 or $conn2 ?
$result=mysql_query("create table db1.some_table LIKE db2.some_table",$conn1) or die(mysql_error());
//and here a similiar problem:
$result=mysql_query("CREATE TABLE db1.some_table SELECT * FROM db2.some_table",$conn1) or die (mysql_error());
//or maybe I completely misunderstand the issue?