无为清净楼资源网 Design By www.qnjia.com

PHP PDO Access链接

复制代码 代码如下:
class DbHelpClass
    {
        private $conn;
        private $qxId;
        private $ret;

        function __construct()
        {
            $path="../../App_Data/sd#f#45G_!.mdb";
            $constr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".realpath($path);
            $this->conn= new PDO("odbc:$constr") or die ("PDO Connection faild.");

        }

        /*读取*/
        function Read($sql,$params=array())
        {
            $bind=$this->conn->prepare($sql);
            $arrKeys=array_keys($params);
            foreach($arrKeys as $row)
            {
                $bind->bindValue(":".$row,$params[$row]);
            }
            $bind->execute() or die('sql error:'.$sql);
            $result=$bind->fetchAll();

            return $result;
        }

        /*添加,修改需调用此方法*/
        function Edit($sql,$params=array())
        {
            $bind=$this->conn->prepare($sql);
            $arrKeys=array_keys($params);
            foreach($arrKeys as $row)
            {
                $bind->bindValue(":".$row,$params[$row]);

            }

            $a=$bind->execute() or die('sql error');
            return $a;
        }
    }
    $dbh =new DbHelpClass();

标签:
PHP数据库,链接类

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com