Beispiel #1
0
 /**
  * Récupère le nombre de place restante d'un vol
  *
  * @param Vol $unVol
  *
  * @return int
  *
  * @throws ErrorSQLException
  */
 public static function getPlaceRestante(Vol $unVol)
 {
     $nbPlace = $unVol->getNbPlace();
     try {
         $conn = MConnexion::getBdd();
         $reqPrepare = $conn->prepare('SELECT * FROM reservation WHERE numVol = ?');
         $reqPrepare->execute(array($unVol->getNumVol()));
         $reqPrepare = $reqPrepare->fetchAll();
         foreach ($reqPrepare as $tabVol) {
             $nbPlace -= $tabVol['nbPers'];
         }
     } catch (PDOException $e) {
         throw new ErrorSQLException('Le vol n\'existe pas');
     }
     return $nbPlace;
 }