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