Example #1
0
 /**
  * Supprime les séances du spectacle $spectacle
  * @param Spectacle $spectacle
  * @throws \Exception
  */
 public static function rmSeancesSpec(Spectacle $spectacle)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         foreach ($spectacle->getLesSeances()->getCollection() as $seance) {
             $reqPrepare = $conn->prepare("DELETE FROM planning WHERE idSeance = ?");
             $reqPrepare->execute(array($seance->getId()));
         }
         $reqPrepare = $conn->prepare("DELETE FROM seance WHERE idSpectacle = ?");
         $reqPrepare->execute(array($spectacle->getId()));
         $conn->commit();
         return true;
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("Les séances du spectacle " . $spectacle->getId() . " n'ont pas pu être supprimées. Détails : <p>" . $e->getMessage() . "</p>");
         return false;
     }
 }