Paradox Database Read Using pxlib and PHP
jamesm
james
Tue Nov 22 22:22:51 PST 2005
I have an application at work that uses a Paradox database to store
product, weight, customer, supplier, source and destination from our
weighbridge.
My boss wants to update the whole thing with the correct numbers from
our new ERP system.
I thought no problem I will just dump all the stuff from the paradox db
and while I can do this with the Borland Desktop Query Tools. I wanted
to be able to be able to automate the process and dump / load from
spreadsheet.
Now here is the cool bit there is a paradox db library on on sourceforge
pxlib.sourceforge.net and php provides a handle into it. so after a bit
of learner level coding i can connect to each db file and retrieve the
current information.
Funny how I couldn't look at all the tables with the M$ driver but pxlib
worked with all of them.
I had to compile php5.x
'./configure' '--with-apxs2=/usr/bin/apxs2' '--with-mysql'
and then edit php.ini to include the extenstion dir and paradox.so
module but after that it was all plain sailing.
; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20041030"
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
extension=paradox.so
This is the script I used to access each table which I ran from the
command line....
<?php
if(!$pxdoc = px_new()) {
/* Error handling */
}
$fp = fopen("Source.DB", "r");
if(!px_open_fp($pxdoc, $fp)) {
/* Error handling */
}
// ...
$myArray = px_get_info($pxdoc);
reset ($myArray);
while (list($key, $val) = each($myArray)) {
echo "$key => $val\n";
}
$int = $myArray["numrecords"];
$myRecord = "";
print "Number of Records is $int\n" ;
for ($i = 0; $i < $int; $i++) {
$myRecord = px_get_record($pxdoc, $i) ;
reset ($myRecord);
while (list($key, $val) = each($myRecord)) {
$Record = $Record . "\t" . $val ;
}
print "$Record\n" ;
$Record = "";
}
px_close($pxdoc);
px_delete($pxdoc);
fclose($fp);
?>
More information about the Linux-users
mailing list