Viewing file: da_sa_smo.php (1.69 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("sa_model.php");
class Da_sa_smo extends Sa_model {
// PK is smo_id
public $smo_id;
public $smo_name;
public $smo_name_eng;
public $smo_fr_date;
public $smo_status;
public $last_insert_id;
function Da_sa_smo() {
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_smo (smo_id, smo_name, smo_name_eng, smo_fr_date, smo_status)
VALUES(?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->smo_id, $this->smo_name, $this->smo_name_eng, $this->smo_fr_date, $this->smo_status));
$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_smo
SET smo_name=?, smo_name_eng=?, smo_fr_date=?, smo_status=?
WHERE smo_id=?";
$this->db->query($sql, array($this->smo_name, $this->smo_name_eng, $this->smo_fr_date, $this->smo_status, $this->smo_id));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->sa_dbname.sa_smo
WHERE smo_id=?";
$this->db->query($sql, array($this->smo_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_smo
WHERE smo_id=?";
$query = $this->db->query($sql, array($this->smo_id));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
} //=== end class Da_sa_smo
?>
|