can i make use of two different connection using different database in a same php file , if yes , then how
Hi Shalini,
you can make different connection using different database.
first make the two object of the database .
For example two DB
$DB_HOST1=array(
"Host"=>"localhost",
"Username"=>"root",
"Password"=>"",
"Database"=>"DB1",
);
$DB_HOST2=array(
"Host"=>"host name or IP",
"Username"=>"abc",
"Password"=>"abc",
"Database"=>"DB2",
);
suppose first is MYSQL
$conn1=mysql_pconnect($DB_HOST1[Host"], $DB_HOST1[["Username"], $DB_HOST1["Password"]);mysql_select_db($DB_HOST1[["Database"],$conn1);
and second is oracle then
strConn="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST = $DB_HOST2["Host"])
(PORT=1521)
)
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=$DB_HOST2["Database"])
)
)
then connect
$conn2=OCIPLogon(DB_HOST2["Username"], DB_HOST2["Password"], $strConn);
Now u have two connection so u can use two databess who is required.
use the object of database in
MYSQL_QUERY("sql statement",connection id object); in case of mysql
but better way to make a class and two different function of different database so when u required other DB them called the class and call a diifferent DB call
Regards,
Sandeep Agrawal