Tuesday, March 22, 2011

making multiple db connection handles


$handle_db1 = mysql_connect(hostname_and_port,user,password);
$handle_db2 = mysql_connect(hostname_and_port,user,password);

mysql_select_db("db1",$handle_db1);
mysql_select_db("db2",$handle_db2);

$query1 = "select * from one";
$query2 = "select * from two";

mysql_query($query1,$handle_db1);
mysql_query($query2,$handle_db2);

?>

stream editing shell/php

place var1,var2,.... inside common file tempale.xml which u need to add values automatically,
eg :- config file with 2 variables, user_name=VAR1 and path=VAR2

inside php file,

$username='udara';
$path='/var/www/mobsync';
$create='cat tempale.xml | sed -e "s/VAR1/'.$username.'/g" | sed -e "s/VAR2 /'.$path.'/g" > template_new.xml';
exec($create);