当前位置:编程学习 > php >>

国外好东西真的多,现在贴上一个访问ACCESS的类!

答案:这是ACCESS的类

<?
Class AccessDBM
{
    var $COUNT = 0;
    var $VALUES = array();
    var $FILE = "";
    var $ERROR = "";
    var $EXISTS = false;
    var $STATIC = false;
    var $EXACT = false;
    var $DBM;

//    Older version of PHP can't do the 'new ClassName(args)'
//    Use initilize() if this is the case.

//    *******************************************************

    function AccessDBM ($dbmFile, $static = 0)
    {
        global $php_errormsg;

        if(!empty($dbmFile))
        {
            if(file_exists($dbmFile))
            {
                $this->EXISTS = true;
            }
            if($static != 0)
            {
                $this->STATIC = true;
            }
            $this->FILE = $dbmFile;
        }
        return;
    }

//    *******************************************************

//    Identical to AccessDBM
    function initialize ($dbmFile, $static = 0)
    {
        global $php_errormsg;

        if(!empty($dbmFile))
        {
            if(file_exists($dbmFile))
            {
                $this->EXISTS = true;
            }
            if($static != 0)
            {
                $this->STATIC = true;
            }
            $this->FILE = $dbmFile;
        }
        return;
    }

//    *******************************************************

    function add_entry ($key, $val)
    {
        $results = 0;
        $dbm = $this->open_dbm();
        if(!$dbm) { return false; }

        if(!(dbmreplace($dbm,$key,$val)))
        {
            if(!(dbmexists($dbm,$key)))
            {
                $this->ERROR = "Fatal error : could not replace $key with $val";
                $this->close_dbm($dbm);
                return false;
            }
        }
        $this->close_dbm($dbm);
        return true;        
    }

//    *******************************************************

    function remove_entry ($Key)
    {
        global $php_errormsg;
        $removed = false;

        $dbm = $this->open_dbm();
        if(!$dbm) { return false; }

        if(dbmexists($dbm,$Key))
        {
            if(!dbmdelete($dbm,$Key))
            {
                if(dbmexists($dbm,$Key))
                {
                    $this->ERROR = "Unable to remove [$Key] : [$php_errormsg]";
                    $this->close_dbm($dbm);
                    return false;
                }
            }
            else
            {
                $this->close_dbm($dbm);
                $removed = true;
            }
        }
        else
        {
            $this->ERROR = "Key [$Key] does not exist";
            $this->close_dbm($dbm);
            return false;
        }
        return true;
    }

//    *******************************************************

    function get_value ($Key)
    {
        $val = "";
        $readOnly =

上一个:我对权限控制系统的看法
下一个:国外的

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,