Example #1
0
 /**
  * Ajoute un spectacle
  * @param Spectacle $spectacle
  * @throws \Exception
  */
 public static function addSpectacle(Spectacle $spectacle)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare("INSERT INTO spectacle (nomSpectacle, nbPlaceSpectacle, typeClasse, typeSpectacle) VALUES (?,?,?,?)");
         $reqPrepare->execute(array($spectacle->getNom(), $spectacle->getNbPlace(), $spectacle->getTypeClasse(), $spectacle->getTypeSpectacle()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("L'ajout du spectacle " . $spectacle->getId() . " a échoué. Détails : <p>" . $e->getMessage() . "</p>");
     }
 }