Viewing file: da_sa_sourcebudget.php (1.52 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("sa_model.php");
class Da_sa_sourcebudget extends Sa_model {
// PK is sb_id
public $sb_id;
public $sb_name;
public $sb_pid;
public $last_insert_id;
function Da_sa_sourcebudget() {
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_sourcebudget (sb_id, sb_name, sb_pid)
VALUES(?, ?, ?)";
$this->db->query($sql, array($this->sb_id, $this->sb_name, $this->sb_pid));
$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_sourcebudget
SET sb_name=?, sb_pid=?
WHERE sb_id=?";
$this->db->query($sql, array($this->sb_name, $this->sb_pid, $this->sb_id));
}
function delete() {
// if there is no primary key, please remove WHERE clause.
$sql = "DELETE FROM $this->sa_dbname.sa_sourcebudget
WHERE sb_id=?";
$this->db->query($sql, array($this->sb_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_sourcebudget
WHERE sb_id=?";
$query = $this->db->query($sql, array($this->sb_id));
if ( $withSetAttributeValue ) {
$this->row2attribute( $query->row() );
} else {
return $query ;
}
}
} //=== end class Da_sa_sourcebudget
?>
|