コード例 #1
0
ファイル: CodigoMapper.php プロジェクト: xrlopez/ABP
 public function votar(Codigo $cod, JuradoPopular $jpop)
 {
     $stmt = $this->db->prepare("INSERT INTO vota_pop values(?,?)");
     $stmt->execute(array($jpop->getId(), $cod->getId()));
     $stmt2 = $this->db->prepare("UPDATE pincho set num_votos=(num_votos + 1) where FK_establecimiento_pinc=?");
     $stmt2->execute(array($cod->getEstablecimiento()));
 }
コード例 #2
0
ファイル: JuradoPopularMapper.php プロジェクト: xrlopez/ABP
 public function delete(JuradoPopular $jPop)
 {
     $stmt = $this->db->query("SET FOREIGN_KEY_CHECKS=0");
     $stmt = $this->db->prepare("DELETE from juradoPopular WHERE id_usuario=?");
     $stmt->execute(array($jPop->getId()));
     $stmt = $this->db->query("SET FOREIGN_KEY_CHECKS=1");
     $stmt = $this->db->prepare("DELETE from usuario WHERE id_usuario=?");
     $stmt->execute(array($jPop->getId()));
 }
コード例 #3
0
ファイル: UsersController.php プロジェクト: xrlopez/ABP
 public function registerPopular()
 {
     $jpop = new JuradoPopular();
     if (isset($_POST["usuario"])) {
         $jpop->setId($_POST["usuario"]);
         $jpop->setNombre($_POST["nombre"]);
         $jpop->setEmail($_POST["correo"]);
         $jpop->setResidencia($_POST["residencia"]);
         $jpop->setTipo("juradoPopular");
         if ($_POST["pass"] == $_POST["repass"]) {
             $jpop->setPassword($_POST["pass"]);
         } else {
             $errors["pass"] = "******";
             $this->view->setVariable("errors", $errors);
             $this->view->render("users", "registerPopular");
             return false;
         }
         try {
             $jpop->checkIsValidForCreate();
             if (!$this->userMapper->usernameExists($_POST["usuario"])) {
                 $this->userMapper->save($jpop);
                 $this->view->setFlash("Usuario " . $jpop->getId() . " registrado.");
                 $this->view->redirect("users", "login");
             } else {
                 $errors = array();
                 $errors["usuario"] = "El usuario ya existe";
                 $this->view->setVariable("errors", $errors);
             }
         } catch (ValidationException $ex) {
             $errors = $ex->getErrors();
             $this->view->setVariable("errors", $errors);
         }
     }
     // Put the User object visible to the view
     $this->view->setVariable("juradoPopular", $jpop);
     $this->view->render("users", "registerPopular");
 }