php Paradox数据库,PHP: Paradox - Manual

这是一个PHP类库,用于处理Paradox数据库文件。它包含了打开、关闭数据库,获取记录数,读取指定行,获取字段信息等功能。类库还提供了日期和时间戳转换为字符串的方法,以及字段值的处理选项,如添加反斜杠和修剪空白。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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);

}

}?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值