Esempio n. 1
0
 /**
  * Récupère un lieu par son nom
  * @param string $name
  * @return Lieu
  * @throws \Exception
  */
 public static function getLieuByName($name)
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->prepare("SELECT * FROM lieu WHERE nomLieu = ?");
         $reqPrepare->execute(array($name));
         $tab = $reqPrepare->fetch();
         $lieu = new Lieu($tab['idLieu'], $tab['nomLieu'], $tab['adrLieu'], $tab['cpLieu'], $tab['villeLieu']);
         $lesSeances = MSeance::getSeancesByLieu($lieu);
         $lieu->setLesSeances($lesSeances);
         return $lieu;
     } catch (\PDOException $e) {
         throw new \Exception("Le lieu {$name} n'existe pas.");
     }
 }