Viewing file: da_amphur.php (1.82 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("ppc_model.php");
class Da_amphur extends Ppc_model {
// PK is amphurId
public $amphurId;
public $amphurName;
public $amphurNameEng;
public $provinceId;
public $used;
public $pbriId;
public $last_insert_id;
function Da_amphur() {
parent::__construct();
$this->load->database('ppc',TRUE);
}
function insert() {
// if there is no auto_increment field, please remove it
$sql = "INSERT INTO $this->ppc_dbname.Amphur (amphurId, amphurName, amphurNameEng, provinceId, used, pbriId)
VALUES(?, ?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->amphurId, $this->amphurName, $this->amphurNameEng, $this->provinceId, $this->used, $this->pbriId));
$this->last_insert_id = $this->db->insert_id();
}
function update() {
// if there is no primary key, please remove WHERE clause.
$sql = "UPDATE $this->ppc_dbname.Amphur
SET amphurName=?, amphurNameEng=?, provinceId=?, used=?, pbriId=?
WHERE amphurId=?";
$this->db->query($sql, array($this->amphurName, $this->amphurNameEng, $this->provinceId, $this->used, $this->pbriId, $this->amphurId));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->ppc_dbname.Amphur
WHERE amphurId=?";
$this->db->query($sql, array($this->amphurId));
}
/*
* You have to assign primary key value before call this function.
*/
function get_by_key($withSetAttributeValue=FALSE) {
$sql = "SELECT *
FROM $this->ppc_dbname.Amphur
WHERE amphurId=?";
$query = $this->db->query($sql, array($this->amphurId));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
function last_insert_id(){
return $this->db->insert_id();
}
} //=== end class Da_amphur
?>
|