public function AnswerDeleteAction()
 {
     $request = Project::getRequest();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $question_id = $request->getKeyByNumber(0);
     $answer_id = $request->getKeyByNumber(1);
     $answer_model = new AnswerModel($answer_id);
     $question_model = new QuestionModel();
     $question_model->load($question_id);
     if ($answer_model->id > 0 && $question_model->id > 0 && $answer_model->question_id == $question_model->id) {
         if ($answer_model->user_id == $user_id || $question_model->user_id == $user_id) {
             $answer_model->delete($answer_model->user_id, $answer_id);
             $question_model->a_count--;
             $question_model->save();
         }
     }
     Project::getResponse()->redirect($request->createUrl('QuestionAnswer', 'ViewQuestion', array($question_model->id)));
 }
 public function deleteAction()
 {
     $questionid = $this->getRequest()->getParam('questionid', '0');
     //删除问题
     $questiontable = new QuestionModel();
     $db = $questiontable->getAdapter();
     $where = $db->quoteInto('id = ?', $questionid);
     $flag0 = $questiontable->delete($where);
     //删除回复
     $answertable = new AnswerModel();
     $db1 = $answertable->getAdapter();
     $where = $db1->quoteInto('questionid = ?', $questionid);
     $answertable->delete($where);
     //查看是否删除干净
     $flag1 = count($db1->query('SELECT * FROM answer WHERE questionid = ?', $questionid)->fetchAll());
     if ($flag0 > 0 && $flag1 == 0) {
         $this->view->info = 'success';
     } else {
         $this->view->info = 'fail';
     }
     $this->_forward('result4', 'globals');
 }