my script exports and odbc database ( access) and exports the data in xml format and compresses it. quite efficient makes a 50MB xml file into 3MB gz file. assuming you're using win32, go grab php4.0.3 for windows which comes with almos any module you'll need. You 'll have to have odbc, and zlib support for the script to work.
I need help with parsing the script on the server to import it in oracle. I'm also working on making it more eficient, like getting only the diff betwin the temp table and the actuall table, so i only gat the changed data, instead of exporting the whole table every time. if you don't use xml, I'm sure you 'll find the odbc calls usefull.
yavor
// Start of script
<?php
$now = time();
$xmlname = "items.xml";
$tablename = "tblStockItems";
$logfile = "status.log";
function get_date(){
return(" (". date("d/m/y H:i:s",time()).") " );
}
function write_debug($str){
global $lp;
print($str."\n");
fwrite($lp,get_date().$str."\n");
}
$lp = fopen($logfile,'a');
write_debug("Start of script ");
$conn = odbc_connect('spanias','','') or die("Couldn't conect");
$SQL = " SELECT * FROM $tablename ";
$cur = odbc_exec($conn,$SQL) or die("Couldn't execute query");
write_debug("The Query is <".$SQL.">");
write_debug("Gave ".odbc_num_rows($cur)." rows result.");
write_debug("Open file.");
$fp = gzopen($xmlname.'.gz','w9');
gzwrite($fp,"<?xml version=\"1.0\"?>\n");
gzwrite($fp,"\t<DATA>\n");
$count = 0;
$factor = 1;
while(odbc_fetch_row($cur)){
$cols = odbc_num_fields($cur);
gzwrite($fp,"\t\t<customer>\n");
for($i=1;$i<$cols;$i++){
gzwrite($fp,"\t\t\t<".odbc_field_name($cur,$i).">");
gzwrite($fp,str_replace("&","chr1",odbc_result($cur,$i)));
gzwrite($fp,"</".odbc_field_name($cur,$i).">\n");
}
gzwrite($fp,"\t\t</customer>\n");
$count++;
// You can delete this to make it more
// eficient, i only use it for debugging
if(!($count % 1000)){
write_debug("\t".$count." rows exported");
}
}
gzwrite($fp,"\t</DATA>\n");
gzclose($fp);
$time = (time() - $now) / 60;
write_debug("It took me $time minutes to do this.Total $count rows were exported");
fclose($lp);
?>
// End of script