Viewing file: da_sa_dm_book.php (2.23 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("sa_model.php");
class Da_sa_dm_book extends Sa_model {
// PK is dmb_id
public $dmb_id;
public $dmb_std_id;
public $dmb_pf_id;
public $dmb_name;
public $dmb_surname;
public $dmb_citizen_id;
public $dmb_cur_id;
public $dmb_year;
public $dmb_tm_id;
public $dmb_dm_id;
public $dmb_num_month;
public $last_insert_id;
function __construct() {
parent::__construct();
$this->load->database('esa',TRUE);
}
function insert() {
// if there is no auto_increment field, please remove it
$sql = "INSERT INTO $this->sa_dbname.sa_dm_book (dmb_id, dmb_std_id, dmb_pf_id, dmb_name, dmb_surname, dmb_citizen_id, dmb_cur_id, dmb_year, dmb_tm_id, dmb_dm_id, dmb_num_month)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->dmb_id, $this->dmb_std_id, $this->dmb_pf_id, $this->dmb_name, $this->dmb_surname, $this->dmb_citizen_id, $this->dmb_cur_id, $this->dmb_year, $this->dmb_tm_id, $this->dmb_dm_id, $this->dmb_num_month));
$this->last_insert_id = $this->db->insert_id();
}
function update() {
// if there is no primary key, please remove WHERE clause.
$sql = "UPDATE $this->sa_dbname.sa_dm_book
SET dmb_std_id=?, dmb_pf_id=?, dmb_name=?, dmb_surname=?, dmb_citizen_id=?, dmb_cur_id=?, dmb_year=?, dmb_tm_id=?, dmb_dm_id=?, dmb_num_month=?
WHERE dmb_id=?";
$this->db->query($sql, array($this->dmb_std_id, $this->dmb_pf_id, $this->dmb_name, $this->dmb_surname, $this->dmb_citizen_id, $this->dmb_cur_id, $this->dmb_year, $this->dmb_tm_id, $this->dmb_dm_id, $this->dmb_num_month, $this->dmb_id));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->sa_dbname.sa_dm_book
WHERE dmb_id=?";
$this->db->query($sql, array($this->dmb_id));
}
/*
* You have to assign primary key value before call this function.
*/
function get_by_key($withSetAttributeValue=FALSE) {
$sql = "SELECT *
FROM $this->sa_dbname.sa_dm_book
WHERE dmb_id=?";
$query = $this->db->query($sql, array($this->dmb_id));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
} //=== end class Da_sa_dm_book
?>
|