Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi! i want to create a tiny php script, which suppose is to copy data from one table (firebird db) into mysql one. My current code is below - currently it only displays one column but just like i mentioned - i want to copy its values to second db.

Few questions/issues: - how to grab table in total and make an INSERT statement? I simply can't make phpmyadmin import/export -> it must be done via php. - how to grab that data without copying same data all the time.. so the question would be -> how to verify data in newtable and oldtable?

thanks!

What I have tried:

PHP
<?php
// important! - to run this script in specific intervals - set task schedule/cron in windows

// Connection
// ### FIREBIRD ###
$db = "F:\Data.gdb";
$dbuser = "sysdba";
$dbpass = "masterkey";
$res = ibase_connect($db,$dbuser,$dbpass) or die("<br>" . ibase_errmsg());

// ### MYSQL ###
$dbhost = "localhost";
$dbname = "localhost_t1";
$username = "root";
$password = "";

try {
    $conn = new PDO("mysql:host=$dbhost;dbname=$dbname", $username, $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    print "Connected successfully"; 
    print "<br />";
}
catch(PDOException $e)
    {
    print "Connection failed: " . $e->getMessage();
    print "<br />";
}
// End of connection

// Query
$sql="select * from WIZYTY";

$result=ibase_query($res,$sql) or die(ibase_errmsg());

while($row=ibase_fetch_object($result)){

    print $row->WIZ_ID;
    print '<br />';
}
ibase_free_result($result);
 // End of Query

// Closing
ibase_close($res) or die("<br>" . ibase_errmsg());
?>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900