国外好东西真的多,现在贴上一个访问ACCESS的类!
时间:2007-12-23 来源:不详 作者:迈克DB
}
}
else
{
$this->ERROR = "Key [$Key] does not exist";
$this->close_dbm($dbm);
return false;
}
return true;
}
//*******************************************************
function get_value ($Key)
{
$val = "";
$readOnly = true;
$dbm = $this->open_dbm($readOnly);
if(!$dbm) { return false; }
if(dbmexists($dbm,$Key))
{
$val = dbmfetch($dbm,$Key);
}
$this->close_dbm($dbm);
return $val;
}
//*******************************************************
function open_dbm ($readOnly = false)
{
global $php_errormsg;
if($this->STATIC)
{
if(!(empty($this->DBM)))
{
本文来自织梦
$dbm = $this->DBM;
return ($dbm);
}
}
$fileName = $this->FILE;
if(!$this->EXISTS)
{
$dbm = @dbmopen($fileName,"n");
}
else
{
if(!$readOnly)
{
// We want the warning here if we can't be
// a writer
$dbm = dbmopen($fileName,"w");
}
else
{
$dbm = @dbmopen($fileName,"r");
}
}
if( (!$dbm) or (empty($dbm)) )
{
$this->EXISTS = false;
$this->STATIC = false;
$this->ERROR = "Unable to open [$fileName] [$php_errormsg]";
return false;
}
$this->EXISTS = true;
if($this->STATIC)
{
$this->DBM = $dbm;
}
return ($dbm);
} dedecms.com
//*******************************************************
function find_key ($search)
{
$val = "";
$dbm = $this->open_dbm(1);
if(!$dbm) { return false; }
if(dbmexists($dbm,$search))
{
// Wow an exact match
$val = dbmfetch($dbm,$search);
$this->close_dbm($dbm);
$this->EXACT = true;
return $val;
}
else
{
$this->EXACT = false;
$key = dbmfirstkey($dbm);
while ($key)
{
// Strip the first whitespace char and
// everything after it.
$test = ereg_replace(" .*","",$key);
if(eregi("^$test",$search))
{
$val = dbmfetch($dbm,$key);
$this->close_dbm($dbm);
error_log("Test [$test] matched [$search]",0);
return $val;
}
$key = dbmnextkey($dbm,$key);

文章评论
共有位Admini5网友发表了评论 查看完整内容