日期:2013-01-24  浏览次数:20384 次

以下是援用片段:
以下为援用的内容:
<?php
    class Access//Access数据库操作类
    {
        var $databasepath,$constr,$dbusername,$dbpassword,$link;//类的属性
        function Access($databasepath,$dbusername,$dbpassword)//结构函数
        {
            $this->databasepath=$databasepath;
            $this->username=$dbusername;
            $this->password=$dbpassword;
            $this->connect();
        }
        
        function connect()//数据库连接函数
        {
            $this->constr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath($this->databasepath); 
            $this->link=odbc_connect($this->constr,$this->username,$this->password,SQL_CUR_USE_ODBC);
            return $this->link;
            //if($this->link) echo "祝贺你,数据库连接成功!";
            //else echo "数据库连接失败!";
        }
        
        function query($sql)//送一个查询字符串到数据库中
        {
            return @odbc_exec($this->link,$sql);
        }
        
        function first_array($sql)//从access数据库中前往一个数组
        {
            return @odbc_fetch_array($this->query($sql));
        }
        
        function fetch_row($query)//前往记录中的一行
        {
            return odbc_fetch_row($query);
        }
        
        function total_num($sql)//取得记录总数
        {
            return odbc_num_rows($this->query($sql));
        &