Viewing file:      da_rg_StudentDomitory.php (1.85 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include_once("my_model.php");
 class Da_rg_StudentDomitory extends My_model {
     // PK is sdmStdId
     // PK is sdmTmId
     // PK is sdmAcY
 
     public $sdmStdId;
     public $sdmTmId;
     public $sdmAcY;
     public $sdmNumMonth;
     public $sdmDmId;
 
     function Da_rg_StudentDomitory() {
         parent::__construct();
         $this->load->database('rg', TRUE);
     }
 
     function insert() {
         // if there is no auto_increment field, please remove it
         $sql = "INSERT INTO $this->rg_dbname.rg_StudentDomitory (sdmStdId, sdmTmId, sdmAcY, sdmNumMonth, sdmDmId)
                 VALUES(?, ?, ?, ?, ?)";
         $this->db->query($sql, array($this->sdmStdId, $this->sdmTmId, $this->sdmAcY, $this->sdmNumMonth, $this->sdmDmId));
         $this->last_insert_id = $this->db->insert_id();
     }
     
     function update() {
         // if there is no primary key, please remove WHERE clause.
         $sql = "UPDATE $this->rg_dbname.rg_StudentDomitory 
                 SET    sdmNumMonth=?, sdmDmId=? 
                 WHERE sdmStdId=? AND sdmTmId=? AND sdmAcY=?";    
         $this->db->query($sql, array($this->sdmNumMonth, $this->sdmDmId, $this->sdmStdId, $this->sdmTmId, $this->sdmAcY));    
     }
     
     function delete() {
         // if there is no primary key, please remove WHERE clause.
         $sql = "DELETE FROM $this->rg_dbname.rg_StudentDomitory
                 WHERE sdmStdId=? AND sdmTmId=? AND sdmAcY=?";
         $this->db->query($sql, array($this->sdmStdId, $this->sdmTmId, $this->sdmAcY));
     }
     
     /*
      * You have to assign primary key value before call this function.
      */
     function get_by_key($withSetAttributeValue=FALSE) {    
         $sql = "SELECT * 
                 FROM $this->rg_dbname.rg_StudentDomitory 
                 WHERE sdmStdId=? AND sdmTmId=? AND sdmAcY=?";
         $query = $this->db->query($sql, array($this->sdmStdId, $this->sdmTmId, $this->sdmAcY));
         if ( $withSetAttributeValue ) {
             $this->row2attribute( $query->row() );
         } else {
             return $query ;
         }
     }
 
 
 } //=== end class Da_rg_StudentDomitory
 
 ?>
  |