A bit updated version of wilson's class
var$doc=NULL;
var$file=NULL;
var$row=NULL;
var$field_default_value="";
var$field_slashes=false;
var$field_trim=false;
functionOpen($filename) {$this->doc=px_new();
if (!$this->doc) {
die("Paradox Error: px_new() failed.");
}$this->file=fopen($filename,"r");
if (!$this->file) {px_delete($this->doc);
die("Paradox Error: fopen failed. Filename:$filename");
}
if (!px_open_fp($this->doc,$this->file)) {px_delete($this->doc);fclose($this->file);
die("Paradox Erro: px_open_fp failed.");
}
returntrue;
}
functionClose() {
if ($this->doc) {px_close($this->doc);px_delete($this->doc);
}
if ($this->file) {fclose($this->file);
}
}
functionGetNumRows() {
returnpx_numrecords($this->doc);
}
functionGetRow($id) {
try {$this->row=px_get_record($this->doc,$id);
throw newException('no record');
} catch (Exception $e) {
return"Exception: ".$e->getMessage() ."\n";
}
return$this->row;
}
functionGetRows($num=0) {
if (function_exists(px_retrieve_record)) {
returnpx_retrieve_record($this->doc,$num);
} else {
return"Unsupported function (px_retrieve_record) in paradox ext.";
}
}
functionGetSchema() {
returnpx_get_schema($this->doc);
}
functionGetInfo() {
returnpx_get_info($this->doc);
}
functionGetStringfromDate($date,$format="d.m.Y") {
returnpx_date2string($this->doc,$date,$format);
}
functionGetStringfromTimestamp($date,$format="d.m.Y H:i:s") {
returnpx_timestamp2string($this->doc,$date,$format);
}
functionGetField($field,$trim=0,$slash=0) {
if (!$this->row) {
returnfalse;
}$value= isset($this->row[$field]) ?$this->row[$field] :$this->field_default_value;
if ($this->field_slashesor$slash) {$value=addslashes($value);
}
if ($this->field_trimor$trim) {$value=trim($value);
}
return$value;
}
functionGetFieldInfo($id=0) {
returnpx_get_field($this->doc,$id);
}
}?>