Posted in PHP onDecember 05, 2013
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数据库链接类(PDO+Access)实例分享
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@