Viewing file: da_level.php (1.83 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("ppc_model.php");
class Da_level extends Ppc_model {
// PK is levelId
public $levelId;
public $levelName;
public $levelNameEng;
public $levelAbbr;
public $levelAbbrEng;
public $pbriId;
public $last_insert_id;
function Da_level() {
parent::__construct();
$this->load->database('ppc',TRUE);
}
function insert() {
// if there is no auto_increment field, please remove it
$sql = "INSERT INTO $this->ppc_dbname.Level (levelId, levelName, levelNameEng, levelAbbr, levelAbbrEng, pbriId)
VALUES(?, ?, ?, ?, ?, ?)";
$this->db->query($sql, array($this->levelId, $this->levelName, $this->levelNameEng, $this->levelAbbr, $this->levelAbbrEng, $this->pbriId));
$this->last_insert_id = $this->db->insert_id();
}
function update() {
// if there is no primary key, please remove WHERE clause.
$sql = "UPDATE $this->ppc_dbname.Level
SET levelName=?, levelNameEng=?, levelAbbr=?, levelAbbrEng=?, pbriId=?
WHERE levelId=?";
$this->db->query($sql, array($this->levelName, $this->levelNameEng, $this->levelAbbr, $this->levelAbbrEng, $this->pbriId, $this->levelId));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->ppc_dbname.Level
WHERE levelId=?";
$this->db->query($sql, array($this->levelId));
}
/*
* You have to assign primary key value before call this function.
*/
function get_by_key($withSetAttributeValue=FALSE) {
$sql = "SELECT *
FROM $this->ppc_dbname.Level
WHERE levelId=?";
$query = $this->db->query($sql, array($this->levelId));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
function last_insert_id(){
return $this->db->insert_id();
}
} //=== end class Da_level
?>
|