Viewing file:      da_sa_position.php (1.76 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 
 include_once("sa_model.php");
 
 class Da_sa_position extends Sa_model {        
     
     // PK is pos_id
     
     public $pos_id;
     public $pos_name;
     public $pos_status;
     public $pos_type;
     public $pos_seq;
     public $pos_num;
 
     public $last_insert_id;
 
     function Da_sa_position() {
         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_position (pos_id, pos_name, pos_status, pos_type, pos_seq, pos_num)
                 VALUES(?, ?, ?, ?, ?, ?)";
         $this->db->query($sql, array($this->pos_id, $this->pos_name, $this->pos_status, $this->pos_type, $this->pos_seq, $this->pos_num));
         $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_position 
                 SET    pos_name=?, pos_status=?, pos_type=?, pos_seq=?, pos_num=?
                 WHERE pos_id=?";    
         $this->db->query($sql, array($this->pos_name, $this->pos_status, $this->pos_type, $this->pos_seq, $this->pos_num, $this->pos_id));    
     }
     
     function delete() {
         // if there is no primary key, please remove WHERE clause.
         $sql = "DELETE FROM  $this->sa_dbname.sa_position
                 WHERE pos_id=?";
         $this->db->query($sql, array($this->pos_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_position 
                 WHERE pos_id=?";
         $query = $this->db->query($sql, array($this->pos_id));
         if ( $withSetAttributeValue ) {
             $this->row2attribute( $query->row() );
         } else {
             return $query ;
         }
     }
     
 }     //=== end class Da_sa_position
 ?>
  |