Create a gist now

Instantly share code, notes, and snippets.

<?php
// Connection
$db='10.0.0.x:/var/lib/firebird/2.5/data/mysql2firebird.fdb';
$dbuser = 'SYSDBA';
$dbpass = '*******';
$res = ibase_connect($db,$dbuser,$dbpass) or die("<br>" . ibase_errmsg());
$row = 1;
$handle = fopen("mysqltable_dump.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
// echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
if ($data[$c]=="") {$data[$c]="null";}
// echo $data[$c] . "<br />\n";
}
$query="insert into firebird_table_name(firestcolumn_id,second_column,third_column) values (".$data[0].",".$data[1].','.$data[2].");";
echo "$query\n";
$result=ibase_query($res,$query);
ibase_commit($res);
if (!$result) {
echo "Error. Can't insert the record with the query: $query!";
exit;
}
}
fclose($handle);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment