Viewing file:      mo_rg_studentabsent.php (4.31 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include_once("da_rg_StudentAbsent.php");
 class Mo_rg_studentabsent extends Da_rg_StudentAbsent {
     
     /**
      * หน้าที่ของฟังก์ชั่น คือ หาข้อมูลการลา/ขาดของนักศึกษา ตามเงื่อนไข
      *
      * @access    public
      * @param    array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขของคำสั่ง SELECT
      * @param    array order โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการเรียงลำดับ ORDER BY
      * @param    array group โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการจัดกลุ่ม GROUP BY
      * @return    query >= 1 rows : rg_StudentAbsent.*
      * @todo    use
      */
     public function qrySab($condition="",$order="",$group="") {
         $where = $this->checkCondition($condition);
         $order = $this->checkOrderBy($order);
         $group = $this->checkGroupBy($group);
 
         $c1 = substr($where, 0, -3);
         $c2 = substr($order, 0, -1);
         $c3 = substr($group, 0, -1);
 
         $sql = "SELECT *
                     FROM $this->rg_dbname.rg_StudentAbsent
                     $c1
                     $c3
                     $c2";
         $query = $this->db->query($sql);
         return $query;
     }
 
     /**
      * หน้าที่ของฟังก์ชั่น คือ หาข้อมูลการลา/ขาดของนักศึกษา และข้อมูลชั้นปีตามเงื่อนไข
      *
      * @access    public
      * @param    array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขของคำสั่ง SELECT
      * @param    array order โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการเรียงลำดับ ORDER BY
      * @param    array group โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการจัดกลุ่ม GROUP BY
      * @return    query >= 1 rows : rg_StudentAbsent.*, rg_StudyYear.*
      * @todo    use
      */
     function qrySabJoinSy($condition="",$order="",$group="") {
         $where = $this->checkCondition($condition);
         $order = $this->checkOrderBy($order);
         $group = $this->checkGroupBy($group);
 
         $c1 = substr($where, 0, -3);
         $c2 = substr($order, 0, -1);
         $c3 = substr($group, 0, -1);
 
         $sql = "SELECT *
                 FROM $this->rg_dbname.rg_StudentAbsent
                 LEFT JOIN $this->rg_dbname.rg_StudyYear ON SabSyId=syId
                 $c1
                 $c3
                 $c2";
         $query = $this->db->query($sql);
         return $query;
     }
 
     public function qryBetWeenDateNotSabStdId($sabFrDate,$sabToDate,$sabStdId) {
         $sql = "SELECT *
                 FROM $this->rg_dbname.rg_StudentAbsent
                 WHERE sabToDate>=?
                 AND sabFrDate<=?
                 AND sabStdId=?";
         $query = $this->db->query($sql,array($sabFrDate,$sabToDate,$sabStdId));
         return $query;
     }
 
     /**
      * หน้าที่ของฟังก์ชั่น คือ หาลำดับการขาดลาที่มากที่สุด ของนักศึกษาแต่ละคน
      *
      * @access    public
      * @param    $sacStdId : รหัสนักศึกษา
      * @return    sabSeq : ลำดับการลา/ขาดที่มากที่สุด
      * @todo    use
      */
     function getNextSabSeqBySabStdId($sabStdId) {
         $sql = "SELECT IFNULL(MAX(sabSeq),0) + 1 AS sabSeq
                 FROM $this->rg_dbname.rg_StudentAbsent
                 WHERE sabStdId=?";
         $query = $this->db->query($sql,array($sabStdId));
         return $query->row()->sabSeq;
     }
 
     function qrySabBySabStdIdAndGEAdYJoinSy($sabStdId,$sabAcY) {
         $sql = "SELECT *
                 FROM rg_StudentAbsent
                 LEFT JOIN rg_StudyYear ON sabSyId=syId
                 WHERE sabStdId=?
                 AND sabAcY>=?
                 ORDER BY sabToDate DESC";
         $query = $this->db->query($sql,array($sabStdId,$sabAcY));
         return $query;
     }
 }
 ?>
  |