<?php class DBDA { public $host = "localhost"; public $uid = "root"; public $pwd = "20982239"; //执行sql语句,返回相应的结果函数 //$sql是要执行的sql语句 //$type是sql语句的类型,0代表增删改,1代表查询 //$db代表要操作的数据库 public function Query($sql,$type=1,$db="…
Ajax调用json封装代码<dbda.php>: //Ajax调用返回JSON public function JsonQuery($sql,$type=1,$db="mydb") { //定义数据源 $dsn = "mysql:dbname={$db};host={$this->host}"; //造pdo对象 $pdo = new PDO($dsn,"{$this->uid}","{$this->pw…