20,359
社区成员
发帖
与我相关
我的任务
分享
<?php
include_once("incClass.php");
class DAO{
protected $conn;
protected $table;
public $errors;
function __construct($table){
$this->conn = getConn();
$this->table = $table;
$this->errors = false;
}
function get($Id){
$rs = $this->conn->execute("select * from $this->table where id =$Id");
return $rs->GetArray();
}
function save($fields,$Id = false){
if (!$Id) {
//insert
$rs=$this->conn->Execute("SELECT * FROM $this->table");
$insertSQL = $this->conn->GetInsertSQL($rs, $fields);
$this->conn->Execute($insertSQL);
if ($this->conn->ErrorMsg()) $this->errors = $this->conn->ErrorMsg();
}
else {
//update
$rs=$this->conn->Execute("SELECT * FROM $this->table where id=$Id");
$updateSQL = $this->conn->GetUpdateSQL($rs, $fields);
$this->conn->Execute($updateSQL);
//if ($this->conn->ErrorMsg()) $this->errors= $this->conn->ErrorMsg();
}
}
function delete($Id){
$sql="delete from $this->table where id=$Id";
$this->conn->execute($sql);
if ($this->conn->ErrorMsg()) $this->errors= $this->conn->ErrorMsg();
}
}
class IdbDao extends DAO {
function __construct(){
parent::__construct("idb");
}
function delete($id){
$sql = "delete from amendsdetaildb where Iid=$id";
$this->conn->execute($sql);
parent::delete($id);
}
}
class AdmendsDetailDbDAO extends DAO {
function __construct(){
parent::__construct("amendsdetaildb");
}
function getDetail($Iid){
$rs = $this->conn->execute("select * from $this->table where Iid =$Iid");
return $rs->GetArray();
}
}
class ObjectDbDAO extends DAO {
function __construct(){
parent::__construct("objectdb");
}
}
?>