Beispiel #1
0
 public function execute()
 {
     $db = Connexion::getConnexion();
     $statement = $db->prepare("DELETE FROM shows WHERE id = ?");
     $statement->bindValue(1, $_POST["id"], PDO::PARAM_INT);
     $statement->execute();
 }
 public function __construct($dbhost, $dbname, $user, $password)
 {
     $this->host = $dbhost;
     $this->dbname = $dbname;
     $this->user = $user;
     $this->password = $password;
     $this->bdd = Connexion::getConnexion($dbhost, $dbname, $user, $password);
 }
Beispiel #3
0
 public static function addShow($name, $season, $nb_epi_total, $status)
 {
     $db = Connexion::getConnexion();
     $statement = $db->prepare("INSERT INTO shows (name,season,nb_episodes_total,status) VALUES(?,?,?,?)");
     $statement->bindValue(1, $name, PDO::PARAM_STR);
     $statement->bindValue(2, $season, PDO::PARAM_STR);
     $statement->bindValue(3, $nb_epi_total, PDO::PARAM_INT);
     $statement->bindValue(4, $status, PDO::PARAM_INT);
     $statement->execute();
 }
Beispiel #4
0
 public static function obtenirLeClassement($idClassement)
 {
     try {
         $conn = Connexion::getConnexion();
         $sql_matches = "select e1.nom as equipe_1, e2.nom as equipe_2, scoreEquipe1, scoreEquipe2, joue FROM championnats INNER JOIN journees ON journees.id_championnats = championnats.id INNER JOIN matches_basket ON id_journees = journees.id INNER JOIN equipes e1 ON id_equipe1 = e1.id INNER JOIN equipes e2 ON id_equipe2 = e2.id WHERE championnats.id = :Classement";
         $sth1 = $conn->prepare($sql_matches);
         $c = array("Classement" => $idClassement);
         $sth1->execute($c);
         $matches = $sth1->fetchALL(PDO::FETCH_CLASS);
         $sql_equipes = "select nom FROM equipes where id_championnats = :Classement";
         $sth2 = $conn->prepare($sql_equipes);
         $tabE = array("Classement" => $idClassement);
         $sth2->execute($tabE);
         $equipes = $sth2->fetchALL(PDO::FETCH_CLASS);
         /* a partir de la, a verifier */
         $rEquipes = array("nom" => $equipes, "points" => array(), "joues" => array(), "victoires" => array(), "nuls" => array(), "defaites" => array());
         foreach ($matches as $match) {
             if ($match['joue'] == 1) {
                 if ($match['equipe_1'] === $rEquipes['nom']) {
                     if ($match['scoreEquipe1'] > $match['scoreEquipe2']) {
                         $rEquipes['points'] += 3;
                         $rEquipes['victoires'] += 1;
                     }
                     if ($match['scoreEquipe1'] == $match['scoreEquipe2']) {
                         $rEquipes['points'] += 1;
                         $rEquipes['nuls'] += 1;
                     }
                     if ($match['scoreEquipe1'] > $match['scoreEquipe2']) {
                         $rEquipes['defaites'] += 1;
                     }
                     $rEquipes['joues'] += 1;
                 }
                 if ($match['equipe_2'] === $rEquipes['nom']) {
                     if ($match['scoreEquipe1'] > $match['scoreEquipe2']) {
                         $rEquipes['points'] += 3;
                         $rEquipes['victoires'] += 1;
                     }
                     if ($match['scoreEquipe1'] == $match['scoreEquipe2']) {
                         $rEquipes['points'] += 1;
                         $rEquipes['nuls'] += 1;
                     }
                     if ($match['scoreEquipe1'] > $match['scoreEquipe2']) {
                         $rEquipes['defaites'] += 1;
                     }
                     $rEquipes['joues'] += 1;
                 }
             }
         }
         return $rEquipes;
     } catch (PDOException $e) {
         $erreur = $e->getMessage();
     }
 }
Beispiel #5
0
 public function execute()
 {
     $db = Connexion::getConnexion();
     $statement = $db->prepare("SELECT nb_episodes_watched, nb_episodes_total FROM shows WHERE id = ?");
     $statement->bindValue(1, $_POST["id"], PDO::PARAM_INT);
     $statement->execute();
     $result = $statement->fetchAll(PDO::FETCH_ASSOC);
     $previousValue = $result[0]["nb_episodes_watched"];
     $total = $result[0]["nb_episodes_total"];
     $statement = $db->prepare("UPDATE shows SET nb_episodes_watched=? WHERE id=?");
     $statement->bindValue(1, $previousValue + 1, PDO::PARAM_INT);
     $statement->bindValue(2, $_POST["id"], PDO::PARAM_INT);
     $statement->execute();
     $returnValue = array($previousValue + 1, $total);
     return $returnValue;
 }
Beispiel #6
0
 public function execute()
 {
     Connexion::getConnexion();
     if (!empty($_GET["logout"])) {
         if (!$_SESSION["logout"]) {
             session_unset();
             session_destroy();
             session_start();
             $_SESSION["logout"] = true;
         }
     }
     if (empty($_SESSION["visibility"])) {
         $_SESSION["visibility"] = CommonAction::$VISIBILITY_PUBLIC;
     }
     if ($_SESSION["visibility"] < $this->pageVisibility) {
         header("location:index");
         exit;
     }
     $this->executeAction();
     Connexion::closeConnexion();
 }
<?php

require_once "../templates/connexion.php";
//On créer un objet connexion:
$c = new Connexion();
$connexion = $c->getConnexion();
//Si on ajoute une oeuvre
if (!empty($_GET['idOeuvreAttente'])) {
    $idOeuvreAttente = $_GET['idOeuvreAttente'];
}
//Si on supprime une oeuvre
if (!empty($_GET['idOeuvreValidee'])) {
    $idOeuvreValidee = $_GET['idOeuvreValidee'];
}
//Pour supprimer l'oeuvre de la table des oeuvres validées
if (!empty($idOeuvreValidee)) {
    $connexion->exec("DELETE FROM `oeuvre_validee` WHERE idOeuvre='" . $idOeuvreValidee . "'");
    header("Location: jury.php?msg=1");
    exit;
}
//Pour ajouter l'oeuvre non validée dans les validées
if (!empty($idOeuvreAttente)) {
    $resultats = $connexion->prepare("INSERT INTO `oeuvre_validee` SELECT * FROM `oeuvre_attente`WHERE idOeuvre='" . $idOeuvreAttente . "'");
    $resultats->execute();
    /*//On récupère tous les attributs de la ligne
    		$requete = $connexion->query("SELECT * FROM `oeuvre_attente` WHERE idOeuvre='".$idOeuvreAttente."'");
    		$requete->setFetchMode(PDO::FETCH_OBJ);
    		$resultat = $requete->fetch();
            
            $idArtiste = $resultat->idArtiste;
    		$nomOeuvre = $resultat->nomOeuvre;
 public function __construct()
 {
     $instance = new Connexion();
     $this->connexion = $instance->getConnexion();
 }
 public function persist($obj)
 {
     $table = $obj->table;
     $columns = $obj->columns;
     $infos = $obj->infos;
     $exist = $this->getById($table, $obj->id);
     if (empty($exist)) {
         self::$queryType = strtoupper('insert');
         $query = 'INSERT INTO ' . $table;
         $query .= '(' . implode(', ', $columns);
         $query .= ') VALUE (';
         for ($i = 0; $i < count($infos) - 1; $i++) {
             $query .= '"' . $infos[$i] . '", ';
         }
         $query .= '"' . $infos[count($infos) - 1] . '"';
         $query .= ');';
         var_dump($query);
         $prepare = parent::getConnexion()->prepare($query);
         self::$prepare = $prepare;
         $prepare->execute();
     } else {
         $this->update($table, $columns, $infos, 'id', $infos[0]);
     }
 }
Beispiel #10
0
 public function __construct($host, $dbname, $dbuser, $dbpass)
 {
     $this->bdd = Connexion::getConnexion($host, $dbname, $dbuser, $dbpass);
 }