-2
$db1 = mysql_connect('host1', 'user', 'user'); 
$db2 = mysql_connect('host2', 'user', 'user', true); 

mysql_select_db('db1', $db1);
mysql_select_db('db2', $db2);


mysql_query("select * from table1");

which db connection will be used if connection object not provided in query?

user991554
  • 173
  • 1
  • 12

1 Answers1

0

Read the documentation (http://uk1.php.net/manual/en/function.mysql-query.php):

link_identifier

The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.

So in your case, db2.

Paulina
  • 554
  • 3
  • 8