Viewing file:      mo_rg_faq.php (2.2 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include_once("da_rg_Faq.php");
 class Mo_rg_faq extends Da_rg_Faq {
 
     /**
      * หน้าที่ของฟังก์ชั่น คือ หาคำถามที่พบบ่อยตามเงื่อนไข
      *
      * @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_Faq.*
      * @todo    use
      */
     public function qryFaq($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_Faq
                 $c1
                 $c3
                 $c2";
         $query = $this->db->query($sql);
         return $query;
     }
 
     /**
      * หน้าที่ของฟังก์ชั่น คือ หารหัสคำถามที่มากที่สุด
      *
      * @access    public
      * @return    faqId: รหัสคำถาม
      * @todo    use
      */
     public function qryMaxFaqId() {
         $sql = "SELECT MAX(faqId) AS faqId
                     FROM $this->rg_dbname.rg_Faq";
         $query = $this->db->query($sql);
         if($query->num_rows()) {
             return $query->row()->faqId+1;
         } else {
             return 1;
         }
     }
 
     public function qryFaqNotId($condition="",$faqId) {
         $where = $this->checkCondition($condition);
 
         $c1 = substr($where, 0, -3);
 
         $sql = "SELECT * 
                 FROM $this->rg_dbname.rg_Faq 
                 $c1
                 AND faqId<>?";
         $query = $this->db->query($sql,array($faqId));
         return $query;
     }
 }
 ?>
  |