一个访问ACCESS的类
eturn false;
}
while ( list ( $key, $val ) = each ($dbase) )
{
if($search == $val)
{
$this->exact=true;
return $key;
}
else
{
// strip the first whitespace char and
// everything after it.
$test = ereg_replace(" .*","",$val);
if(eregi("^$test",$search))
{
$this->exact = false;
return $key;
}
}
}
// didn't find it
return false;
}
// *******************************************************
function get_all ()
{
$values = array();
$count = 0;
$readonly = true;
$dbm = $this->open_dbm($readonly);
if(!$dbm) { return false; }
$key = dbmfirstkey($dbm);
while ($key)
{
$val = dbmfetch($dbm,$key);
$values[$key] = $val;
$count++;
$key = dbmnextkey($dbm, $key);
}
$this->count = $count;
$this->values = $values;
$this->close_dbm($dbm);
return $values;
}
// *******************************************************
function close_dbm ($dbm)
{
$results = false;
if(!$this->static)
{
$results = dbmclose($dbm);
}
return $results;
}
// *******************************************************
function static_close()
{
$results = false;
if(!$this->dbm)
{
$this->error = "no static dbm to close";
return false;
}
$dbm = $this->dbm;
$results = dbmclose($dbm);
unset($this->dbm);
return $results;
}
// *******************************************************
}
?>
这个连接上!
include("class.accessdbm.php3");
$static = true;
$dbase = new accessdbm("/path/to/file.dbm",$static);
register_shutdown_function($dbase->static_close());
if(!$dbase->add_entry("cdi","cdi@thewebmasters.net))
{
echo "error adding entry: $dbase->error\n";
}
$values = $dbase->get_all()
while ( list ($key,$val) = each ($values) )
{
echo "key: $key val: $val \n";
}
exit;
}
while ( list ( $key, $val ) = each ($dbase) )
{
if($search == $val)
{
$this->exact=true;
return $key;
}
else
{
// strip the first whitespace char and
// everything after it.
$test = ereg_replace(" .*","",$val);
if(eregi("^$test",$search))
{
$this->exact = false;
return $key;
}
}
}
// didn't find it
return false;
}
// *******************************************************
function get_all ()
{
$values = array();
$count = 0;
$readonly = true;
$dbm = $this->open_dbm($readonly);
if(!$dbm) { return false; }
$key = dbmfirstkey($dbm);
while ($key)
{
$val = dbmfetch($dbm,$key);
$values[$key] = $val;
$count++;
$key = dbmnextkey($dbm, $key);
}
$this->count = $count;
$this->values = $values;
$this->close_dbm($dbm);
return $values;
}
// *******************************************************
function close_dbm ($dbm)
{
$results = false;
if(!$this->static)
{
$results = dbmclose($dbm);
}
return $results;
}
// *******************************************************
function static_close()
{
$results = false;
if(!$this->dbm)
{
$this->error = "no static dbm to close";
return false;
}
$dbm = $this->dbm;
$results = dbmclose($dbm);
unset($this->dbm);
return $results;
}
// *******************************************************
}
?>
这个连接上!
include("class.accessdbm.php3");
$static = true;
$dbase = new accessdbm("/path/to/file.dbm",$static);
register_shutdown_function($dbase->static_close());
if(!$dbase->add_entry("cdi","cdi@thewebmasters.net))
{
echo "error adding entry: $dbase->error\n";
}
$values = $dbase->get_all()
while ( list ($key,$val) = each ($values) )
{
echo "key: $key val: $val \n";
}
exit;
