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))); }
session_start(); include_once '../includes/connection.php'; include_once '../includes/Contest.php'; include_once '../includes/tipoRespuesta.php'; include_once '../PDO/ContestModel.php'; include_once '../includes/Answer.php'; include_once '../PDO/AnswerModel.php'; $tipo = new TipoRespuesta(); if (isset($_SESSION['name']) and $_SESSION['id'] == '10207674962976867') { $id_event = $_GET['id_event']; $id_type = $_GET['id_type']; $contest = new Contest(); $contestModel = new ContestModel(); $answer = new Answer(); $answerModel = new AnswerModel(); $tipos = $tipo->fetch_all(); if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'update': $contest->__SET('id_event', $_REQUEST['id_event']); $contest->__SET('name', $_REQUEST['name']); $contest->__SET('question', $_REQUEST['question']); $contest->__SET('id_type', $_REQUEST['tiposelect']); $contest->__SET('initial_date', $_REQUEST['initial_date']); $contest->__SET('final_date', $_REQUEST['final_date']); $contest->__SET('winner', $_REQUEST['winner']); $contest->__SET('active', 1); $contestModel->Update($contest); //echo '<script language="javascript">alert("¡El registro se ha actualizado exitosamente!");</script>'; echo "<script type=\"text/javascript\">\n alert('¡El registro se ha actualizado exitosamente!');\n history.go(-2);\n </script>";
<?php session_start(); include_once '../../TOMO2-Web/includes/connection.php'; include_once '../../TOMO2-Web/includes/Answer.php'; include_once '../../TOMO2-Web/PDO/AnswerModel.php'; include_once '../../TOMO2-Web/includes/Contest.php'; include_once '../../TOMO2-Web/PDO/ContestModel.php'; //include_once ('../img_bbdd/upload.php'); $conc = new Contest(); if (isset($_SESSION['name']) and $_SESSION['id'] == '10207674962976867') { $id_answer = $_GET['id_answer']; $id_event = $_GET['id_event']; $concursos = $conc->fetch_all(); $answer = new Answer(); $answerModel = new AnswerModel(); $image = array(null); $directory = "img_bbdd/helados.jpg"; /* if (isset($_GET['name'], $_GET['description'], $_GET['upload_date'], $_GET['image'], $_GET['link'], $_GET['active'])){ $name = $_GET['name']; $description = nl2br($_GET['description']); $upload_date = $_GET['upload_date']; $link = $_GET['image']; $image = $_GET['link']; $active = $_GET['active']; if (empty($name) or empty($description) or empty($upload_date)){ $error = 'There are some fields empty. The only empty field accepted is "image" or "link" field'; } else { $query = $pdo->prepare('INSERT INTO Noticias (name, description, upload_date, image, link, active) VALUES (?, ?, ?, ?, ?, ?)');
public function myreplyAction() { $page = $this->getRequest()->getParam('page'); $account = $_COOKIE["account"]; $usertable = new UserModel(); $db1 = $usertable->getAdapter(); $answertable = new AnswerModel(); $db3 = $answertable->getAdapter(); //查找当前用户ID $result = $usertable->fetchRow($db1->quoteInto('email = ?', $account))->toArray(); $uid = $result['id']; $num = $db3->query('SELECT COUNT(*) as num FROM answer,User WHERE answer.userid = User.id and User.id =? order by time desc', $uid)->fetchAll()[0][num]; $pages = ceil($num / 3); if ($page == "") { $page = 0; } if ($page < 3) { if ($pages > 3) { $set = array(1, 2, 3, 4); } else { $set = array(); for ($i = 1; $i <= $pages; $i++) { $set[] = $i; } } } else { if ($page >= 3) { if ($page + 3 <= $pages) { $set = array($page, $page + 1, $page + 2, $page + 3); } else { $set = array(); for ($i = $page; $i <= $pages; $i++) { $set[] = $i; } } } } $count = 6; $offset = $page * 6; $select = $db3->select(); $select->from('answer', '*'); $select->join('question', 'answer.questionid=question.id', '*'); $select->where('answer.userid=?', 7)->limit($count, $offset); $sql = $select->__toString(); $questions = $db3->fetchAll($sql); // print_r($questions); /* $where = $db3->quoteInto('userid = ?', 7); $order = 'begin by time desc'; $count = 6; $offset =$page*6; $questions = $answertable->fetchAll($where, $order, $count, $offset)->toArray(); */ $this->view->results = $questions; $this->view->user = $result; $this->view->page = $page; $this->view->count = $set; }