Example #1
0
 /**
  * Récupère la commande dont le numéro est passé en paramètre.
  *
  * @param int $id numéro d'une commande
  *
  * @return Commande $uneCommande
  *
  * @throws ErrorSQLException
  * @throws CollectionException
  */
 public static function getUneCommande($id)
 {
     try {
         $conn = MConnexion::getBdd();
         $req = $conn->prepare('SELECT * FROM commande WHERE numCde = ?');
         $req->execute([$id]);
         $req = $req->fetch();
         $unClient = MUtilisateur::getUnUser($req['numClt']);
         $uneCommande = new Commande($id, $unClient, $req['date'], $req['pointsUtilise']);
         $uneCommande->setLesArticles(MCommander::getUneCommande($uneCommande));
         return $uneCommande;
     } catch (PDOException $e) {
         throw new ErrorSQLException($e->getMessage());
     }
 }