Page 1 of 1

Use of Resource link_identifier in mysql_query

Posted: Sat Aug 07, 2004 5:06 am
by anjanesh
I have two diferent connections :

$Con1=mysql_connect($IP1,$Username1,$Password1);
$Con2=mysql_connect($IP2,$Username2,$Password2);

mysql_select_db($db1,$Con1);
mysql_select_db($db2,$Con2);

This what I tried to do:

$Res1=mysql_query($sql1,$Con1);
$Res2=mysql_query($sql2,$Con2);

All this time I coudn't figure out why it was failing then I found out that I need to select the db again when switching connections :

mysql_select_db($db1,$Con1);$Res1=mysql_query($sql1,$Con1);
mysql_select_db($db2,$Con2);$Res2=mysql_query($sql2,$Con2);

Then only it would work alright. Then whats the point of having the optional resource link_identifier argument in mysql_query() if we need to select_db each time ?

Thanks

Posted: Sat Aug 07, 2004 11:14 am
by feyd
you could try using [php_man]mysql_db_query[/php_man]() :)

Posted: Sat Aug 07, 2004 11:24 am
by anjanesh
mysql_db_query ( string database, string query [, resource link_identifier])
is the same as
mysql_select_db() and then mysql_query()

I was hoping resource link_identifier would be having a unique id for each connection and select the db automatically.

Posted: Sat Aug 07, 2004 11:33 am
by feyd
it looks like mysql_select_db sets a session-wide database to use instead of a connection hook. So you may want to look at the bug database about it.

Posted: Sat Aug 07, 2004 11:36 am
by anjanesh
Alright
Thanks