Viewing file: da_rg_Course.php (3.45 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("my_model.php");
class Da_rg_Course extends My_model {
// PK is crsId
public $crsId;
public $crsCode;
public $crsCodeE;
public $crsName;
public $crsNameE;
public $crsAbbr;
public $crsAbbrE;
public $crsDescription;
public $crsDescriptionE;
public $crsCreditTotal;
public $crsCredit1;
public $crsCredit2;
public $crsPeriod1;
public $crsPeriod2;
public $crsPeriod3;
public $crsUnit;
public $crsShowLabInTS;
public $crsStatus;
public $crsCdId;
public $crsGtpId;
public $crsCreateDate;
public $crsCreateUserId;
public $crsUpdateDate;
public $crsUpdateUserId;
public $last_insert_id;
function Da_rg_Course() {
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_Course (crsId, crsCode, crsCodeE, crsName, crsNameE, crsAbbr, crsAbbrE, crsDescription, crsDescriptionE, crsCreditTotal, crsCredit1, crsCredit2, crsPeriod1, crsPeriod2, crsPeriod3, crsUnit, crsShowLabInTS, crsStatus, crsCdId, crsGtpId, crsCreateDate, crsCreateUserId, crsUpdateDate, crsUpdateUserId)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->crsId, $this->crsCode, $this->crsCodeE, $this->crsName, $this->crsNameE, $this->crsAbbr, $this->crsAbbrE, $this->crsDescription, $this->crsDescriptionE, $this->crsCreditTotal, $this->crsCredit1, $this->crsCredit2, $this->crsPeriod1, $this->crsPeriod2, $this->crsPeriod3, $this->crsUnit, $this->crsShowLabInTS, $this->crsStatus, $this->crsCdId, $this->crsGtpId, $this->crsCreateDate, $this->crsCreateUserId, $this->crsUpdateDate, $this->crsUpdateUserId));
$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_Course
SET crsCode=?, crsCodeE=?, crsName=?, crsNameE=?, crsAbbr=?, crsAbbrE=?, crsDescription=?, crsDescriptionE=?, crsCreditTotal=?, crsCredit1=?, crsCredit2=?, crsPeriod1=?, crsPeriod2=?, crsPeriod3=?, crsUnit=?, crsShowLabInTS=?, crsStatus=?, crsCdId=?, crsGtpId=?, crsCreateDate=?, crsCreateUserId=?, crsUpdateDate=?, crsUpdateUserId=?
WHERE crsId=?";
$this->db->query($sql, array($this->crsCode, $this->crsCodeE, $this->crsName, $this->crsNameE, $this->crsAbbr, $this->crsAbbrE, $this->crsDescription, $this->crsDescriptionE, $this->crsCreditTotal, $this->crsCredit1, $this->crsCredit2, $this->crsPeriod1, $this->crsPeriod2, $this->crsPeriod3, $this->crsUnit, $this->crsShowLabInTS, $this->crsStatus, $this->crsCdId, $this->crsGtpId, $this->crsCreateDate, $this->crsCreateUserId, $this->crsUpdateDate, $this->crsUpdateUserId, $this->crsId));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->rg_dbname.rg_Course
WHERE crsId=?";
$this->db->query($sql, array($this->crsId));
}
/*
* You have to assign primary key value before call this function.
*/
function get_by_key($withSetAttributeValue=FALSE) {
$sql = "SELECT *
FROM $this->rg_dbname.rg_Course
WHERE crsId=?";
$query = $this->db->query($sql, array($this->crsId));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
function last_insert_id(){
return $this->db->insert_id();
}
} //=== end class Da_rg_course
?>
|