i have two kind of database in different server. And the script below is to make DB connection:
//DB 1
define("DBNAME","xx.xxx.xx.xxx:D:\DATABASE\OCS DATA.FDB");
define("DBUSER","USER");
define("DBPASS","USER");
$dbh = ibase_connect(DBNAME,DBUSER,DBPASS) or die(_ERROR15.": ".ibase_errmsg());
//DB 2
$dbc=mysql_connect(_SRV, _ACCID, _PWD) or die(_ERROR15.": ".mysql_error());
mysql_select_db("qdbase") or die(_ERROR17.": ".mysql_error());
beside that,i have some query for insert data into another DB:
//if structure of the both tables are same then...
$sql = "insert into database1.member select * from database2.member";
//if structure of both tables are not same then
$sql = "Insert into database1.member select columnname1,columnname2 ".
"from database2.member";
whether this query can be use for the condition like above, which have two different type of DB? if it so, which part that must be changed?
while ($ibase_row = ibase_fetch_assoc($rResult)){
$ins = array();
foreach ($ibase_row as $col => $val){
$ins[$col] = mysql_real_escape_st开发者_运维百科ring($val);
}
$mysql_insert = "INSERT INTO qdbase.table SET ".implode(',', $ins);
$res = mysql_query($mysql_insert, $dbc) or die();
}
There is a chance that your database systems support "dblink" feature.
If this is available you would link the mysql to Firebird or vice versa and run the script from one of them.
精彩评论