public function Obtain($id_event) { try { $query = $this->pdo->prepare('SELECT * FROM Concursos WHERE id_event = ?'); $query->execute(array($id_event)); $r = $query->fetch(PDO::FETCH_OBJ); $contest = new Contest(); $contest->__SET('id_event', $r->id_event); $contest->__SET('id_type', $r->id_type); $contest->__SET('name', $r->name); $contest->__SET('question', $r->question); $contest->__SET('initial_date', $r->initial_date); $contest->__SET('final_date', $r->final_date); $contest->__SET('winner', $r->winner); $contest->__SET('active', $r->active); return $contest; } catch (Exception $e) { die($e->getMessage()); } }
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>"; break; case 'insert': if ($_REQUEST['winner'] == '') { $_REQUEST['winner'] = 'Sin determinar'; }