예제 #1
0
 public static function getRule($ruleID)
 {
     if ($ruleID) {
         $rule = DB::execute("SELECT entryID, ruleName, userID FROM rules WHERE ruleID='" . ms($ruleID) . "'");
         if (count($rule) > 0) {
             $ruleObj = new Rule($rule["userID"]);
             $ruleObj->setRuleID($ruleID);
             $ruleObj->setEntryID($rule["entryID"]);
             $ruleObj->setRuleName($rule["ruleName"]);
             $keywords = DB::fetchAll("SELECT keyword FROM rules AS r, keyword_entries AS k WHERE ruleID='" . ms($ruleID) . "' AND r.entryID=k.entryID");
             $replies = DB::fetchAll("SELECT messageID FROM reply_msg WHERE ruleID='" . ms($ruleID) . "'");
             $ruleObj->initKeywords($keywords);
             $ruleObj->initReplies($replies);
             return $ruleObj;
         } else {
             if (DEBUG_MODE) {
                 echo "[RuleFactory | getRule] Cannot find rule from DB where ruleID = " . $this->ruleID;
             }
         }
     }
     exit;
 }