Created
September 21, 2010 15:49
-
-
Save mariuz/589903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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