Viewing file: _da_sa_term.php (1.57 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("sa_model.php");
class Da_sa_term extends Sa_model {
// PK is tm_id
public $tm_id;
public $tm_code;
public $tm_name;
public $tm_nameE;
public $tm_default;
public $last_insert_id;
function Da_sa_term() {
parent::__construct();
$this->load->database('esa',TRUE);
}
function insert() {
// if there is no auto_increment field, please remove it
$sql = "INSERT INTO sa_term (tm_id, tm_code, tm_name, tm_nameE, tm_default)
VALUES(?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->tm_id, $this->tm_code, $this->tm_name, $this->tm_nameE, $this->tm_default));
$this->last_insert_id = $this->db->insert_id();
}
function update() {
// if there is no primary key, please remove WHERE clause.
$sql = "UPDATE sa_term
SET tm_code=?, tm_name=?, tm_nameE=?, tm_default=?
WHERE tm_id=?";
$this->db->query($sql, array($this->tm_code, $this->tm_name, $this->tm_nameE, $this->tm_default, $this->tm_id));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM sa_term
WHERE tm_id=?";
$this->db->query($sql, array($this->tm_id));
}
/*
* You have to assign primary key value before call this function.
*/
function get_by_key($withSetAttributeValue=FALSE) {
$sql = "SELECT *
FROM sa_term
WHERE tm_id=?";
$query = $this->db->query($sql, array($this->tm_id));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
} //=== end class Da_sa_term
?>
|