我怎样才能从本地firebird数据库中读取并通过php插入到远程MSSQL服务器数据库中

时间:2014-03-05 08:22:12

标签: php sql-server sql-server-2008 database-connection firebird

任何人都可以告诉我如何从本地firebird数据库中列,并将列值插入到远程Mssql数据库中

从firebird读取列“col1”然后获取数据并将其复制到MSSQL数据库中。

这将帮助我开始我的项目。

注意:我已经连接到两个数据库并检查了连接。

<?PHP /**********************************************/
/************THE FIREBIRDCONNECTION**************/
/**********************************************/

$host = 'localhost:c:\DATABASE.fdb'; 
$username=''; 
$password='';
$dbh = ibase_connect ( $host, $username, $password ) or die ("error in db connect"); //DB connection function
$q="SELECT COLUMN FROM TABLE WHERE CODE = ''"; // query variable

$query = ibase_prepare($q); // prepare the query to read from the DB.. send the q as a prameter 
$result=ibase_execute($query); // after preaparin..run and execute the query .. send the query as a prameter
$showRow = ibase_fetch_row($result); //fitching the row

echo $showRow[0]; // row as an arry

/* free result */ 
ibase_free_query($query); //relase the query
ibase_free_result($result); // show the resulte

/* close db */ 
ibase_close($dbh); // close the connection

echo "</br>";
echo "</br>";



/**********************************************/
/************THE MSSQL CONNECTION**************/
/**********************************************/


// instance name: InstanceName
// database name: DATABASE2
$host = "SERVERNAME\InstanceName";
echo $host;
$connectionInfo = array( "Database"=>"DATABASE2", "UID"=>"", "PWD"=>"");
$conn = sqlsrv_connect( $host, $connectionInfo);

if( $conn === false ) {
    die( print_r( sqlsrv_errors(), true));
} ?>

0 个答案:

没有答案