Viewing file:      da_sa_committee.php (1.9 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 
 include_once("sa_model.php");
 
 class Da_sa_committee extends Sa_model {        
     
     // PK is cmt_id
     
     public $cmt_id;
     public $cmt_year;
     public $cmt_sc_id;
     public $cmt_pos_id;
     public $cmt_std_id;
     public $cmt_fr_date;
     public $cmt_to_date;
 
     public $last_insert_id;
 
     function Da_sa_committee() {
         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_committee (cmt_id, cmt_year, cmt_sc_id, cmt_pos_id, cmt_std_id, cmt_fr_date, cmt_to_date)
                 VALUES(?, ?, ?, ?, ?, ?, ?)";
         $this->db->query($sql, array($this->cmt_id, $this->cmt_year, $this->cmt_sc_id, $this->cmt_pos_id, $this->cmt_std_id, $this->cmt_fr_date, $this->cmt_to_date));
         $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_committee 
                 SET    cmt_year=?, cmt_sc_id=?, cmt_pos_id=?, cmt_std_id=?, cmt_fr_date=?, cmt_to_date=? 
                 WHERE cmt_id=?";    
         $this->db->query($sql, array($this->cmt_year, $this->cmt_sc_id, $this->cmt_pos_id, $this->cmt_std_id, $this->cmt_fr_date, $this->cmt_to_date, $this->cmt_id));    
     }
     
     function delete() {
         // if there is no primary key, please remove WHERE clause.
         $sql = "DELETE FROM  $this->sa_dbname.sa_committee
                 WHERE cmt_id=?";
         $this->db->query($sql, array($this->cmt_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_committee 
                 WHERE cmt_id=?";
         $query = $this->db->query($sql, array($this->cmt_id));
         if ( $withSetAttributeValue ) {
             $this->row2attribute( $query->row() );
         } else {
             return $query ;
         }
     }
     
 }     //=== end class Da_sa_committee
 ?>
  |