Viewing file: da_rg_CurriculumStructure.php (1.97 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("my_model.php");
class Da_rg_CurriculumStructure extends My_model {
// PK is csCurId, csCdId1, csCdId2
public $csCurId;
public $csCdId1;
public $csCdId2;
public $csSeq;
public $csCreditTotal;
public $last_insert_id;
function Da_rg_CurriculumStructure() {
parent::__construct();
$this->load->database('rg', TRUE);
}
function insert() {
// if there is no auto_increment field, please remove it
$sql = "INSERT INTO $this->rg_dbname.rg_CurriculumStructure (csCurId, csCdId1, csCdId2, csSeq, csCreditTotal)
VALUES(?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->csCurId, $this->csCdId1, $this->csCdId2, $this->csSeq, $this->csCreditTotal));
$this->last_insert_id = $this->db->insert_id();
}
function update() {
// if there is no primary key, please remove WHERE clause.
$sql = "UPDATE $this->rg_dbname.rg_CurriculumStructure
SET csSeq=?, csCreditTotal=?
WHERE csCurId=? AND csCdId1=? AND csCdId2=?";
$this->db->query($sql, array($this->csSeq, $this->csCreditTotal, $this->csCurId, $this->csCdId1, $this->csCdId2));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->rg_dbname.rg_CurriculumStructure
WHERE csCurId=? AND csCdId1=? AND csCdId2=?";
$this->db->query($sql, array($this->csCurId, $this->csCdId1, $this->csCdId2));
}
/*
* You have to assign primary key value before call this function.
*/
function get_by_key($withSetAttributeValue=FALSE) {
$sql = "SELECT *
FROM $this->rg_dbname.rg_CurriculumStructure
WHERE csCurId=? AND csCdId1=? AND csCdId2=?";
$query = $this->db->query($sql, array($this->csCurId, $this->csCdId1, $this->csCdId2));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
function last_insert_id(){
return $this->db->insert_id();
}
} //=== end class Da_rg_CurriculumStructure
?>
|