예제 #1
0
 public function view()
 {
     $answerDB = new AnswerModelDB();
     //普通条件,检查GET参数
     $fieldArr = $answerDB->getFields();
     $where = $whereArr = array();
     foreach ($fieldArr as $v) {
         if (array_key_exists($v, $_GET) && $_GET[$v] !== null) {
             $where[] = "`{$v}` = ?";
             $whereArr[] = $_GET[$v];
         }
     }
     $whereStr = count($where) > 0 ? implode(" AND ", $where) : '1=1';
     if (array_key_exists('_search_field', $_GET) && $_GET['_search_field'] != '' && in_array($_GET['_search_field'], $fieldArr, true) && array_key_exists('_search_keyword', $_GET) && $_GET['_search_keyword'] != '') {
         $whereStr = $whereStr == '1=1' ? $_GET['_search_field'] . " LIKE ?" : $whereStr . " AND " . $_GET['_search_field'] . " LIKE ?";
         $whereArr[] = "%" . $_GET['_search_keyword'] . "%";
     }
     //排序条件
     $orderStr = '`id` DESC';
     if (!empty($_POST['order'])) {
         foreach ($_POST['order'] as $k => $v) {
             $orderArr[] = "`{$k}` {$v}";
         }
         $orderStr = implode(',', $orderArr);
     }
     //查询操作
     $sql = "SELECT * FROM `" . $answerDB->getTableName() . "` WHERE {$whereStr} ORDER BY {$orderStr}";
     $data = $answerDB->getData($sql, $whereArr, 20);
     $pageStr = $answerDB->getPageStr();
     //读取外键数据
     $resultDB = new ResultModelDB();
     $questionDB = new QuestionModelDB();
     $questionList = $questionDB->getQuestionList($_GET['vote_id']);
     $resultList = $resultDB->getResultList($_GET['vote_id']);
     $this->setView('questionList', $questionList);
     $this->setView('resultList', $resultList);
     $this->setView('vote_id', $_GET['vote_id']);
     $this->setView('question_id', $_GET['question_id']);
     //模版显示
     $this->setView('pageStr', $pageStr);
     $this->setView('data', $data);
     $this->display('Answer.html');
 }
예제 #2
0
 public function logicResume()
 {
     $questionDB = new QuestionModelDB();
     $updateArr = array('' => 0);
     $whereArr = array();
     $whereArr['id'] = $_GET['id'];
     $rs = $questionDB->update($updateArr, $whereArr);
     Log::write($this->adminUserName, $this->ip, $_GET['id'], self::$controller . "__" . self::$action, $rs);
     $rs ? Message::showSucc('恢复成功') : Message::showError('恢复失败:' . implode(" ", $questionDB->getErrorInfo()));
 }