Viewing file:      sa_rodo_model.php (3.19 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
  include_once("da_sa_rodo.php");
  class Sa_rodo_model extends Da_sa_rodo {
      /*      * aOrderBy = array('fieldname' => 'ASC|DESC', ... )      */     function get_all($aOrderBy=""){         $orderBy = "";         if ( is_array($aOrderBy) ) {             $orderBy.= "ORDER BY ";              foreach ($aOrderBy as $key => $value) {                 $orderBy.= "$key $value, ";             }             $orderBy = substr($orderBy, 0, strlen($orderBy)-2);         }         $sql = "SELECT *                  FROM sa_rodo                  $orderBy";         $query = $this->db->query($sql);         return $query;     }          /*      * create array of pk field and value for generate select list in view, must edit PK_FIELD and FIELD_NAME manually      * the first line of select list is '-----เลือก-----' by default.      * if you do not need the first list of select list is '-----เลือก-----', please pass $optional parameter to other values.       * you can delete this function if it not necessary.      */     function get_options($optional='y') {         $qry = $this->get_all();         if ($optional=='y') $opt[''] = '-----เลือก-----';         foreach ($qry->result() as $row) {             $opt[$row->PK_FIELD] = $row->FIELD_NAME;         }         return $opt;     }          // add your functions here
      function get_by_key_2($withSetAttributeValue=FALSE) {         $sql = "SELECT *                  FROM $this->sa_dbname.sa_rodo                  INNER JOIN $this->rg_dbname.rg_Student ON rd_std_id = stdId                  WHERE rd_id = ?";         $query = $this->db->query($sql, array($this->rd_id));         if ( $withSetAttributeValue ) {             $this->row2attribute( $query->row() );         } else {             return $query ;         }     }
      function get_by_cond($date, $stdCode='', $grade='', $hh_fr_time='', $hh_to_time='', $place='') {         $cond = '';         if ($stdCode) {             $cond .= " OR stdCode LIKE '%$stdCode%'";         }         if ($grade) {             $cond .= " OR rd_grade = '$grade'";         }         if ($hh_fr_time) {             $cond .= " OR rd_fr_time LIKE '%$hh_fr_time%'";         }         if ($hh_to_time) {             $cond .= " OR rd_to_time LIKE '%$hh_to_time%'";         }         if ($place) {             $cond .= " OR rd_place LIKE '%$place%'";         }         $sql = "SELECT *                  FROM $this->sa_dbname.sa_rodo                  INNER JOIN $this->rg_dbname.rg_Student ON rd_std_id = stdId                  INNER JOIN $this->ppc_dbname.Prefix ON stdPfId = prefixId                  WHERE rd_date = ? ".$cond;         $query = $this->db->query($sql, array($date));         return $query;     }
      //pook     function get_by_std($std){         $sql = "SELECT *                  FROM $this->sa_dbname.sa_rodo                  INNER JOIN $this->rg_dbname.rg_Student ON rd_std_id = stdId                  INNER JOIN $this->ppc_dbname.Prefix ON stdPfId = prefixId                  WHERE stdCode LIKE ? OR stdName LIKE ? OR stdSurname LIKE ?";         $query = $this->db->query($sql, array('%'.$std.'%','%'.$std.'%','%'.$std.'%'));         return $query;     }
      function get_by_all() {         $sql = "SELECT *                  FROM $this->sa_dbname.sa_rodo                  WHERE rd_std_id = ?                  AND rd_grade = ?                  AND rd_date = ?                  AND rd_fr_time = ?                  AND rd_to_time = ?                  AND rd_place = ?";         $query = $this->db->query($sql, array($this->rd_std_id, $this->rd_grade, $this->rd_date, $this->rd_fr_time, $this->rd_to_time, $this->rd_place));         return $query;     }          function checkUni($sid,$date){         $sql = "SELECT *                  FROM $this->sa_dbname.sa_rodo                  WHERE rd_std_id = '$sid'                 AND rd_date = '$date'";         $query = $this->db->query($sql);         return $query;     } } // end class M_sa_rodo ?> 
  |