From faec06a43d9096136540d80c46ac39863662ae64 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Wed, 23 Nov 2022 13:05:31 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20fonction=20pour=20faire=20un=20?= =?UTF-8?q?historique=20a=20optimis=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/PartieGateway.php | 21 +++++++++++++++++++++ WEB/Factory/PartieFactory.php | 1 - WEB/Model/Partie.php | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index d94368d9..355955c1 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -35,6 +35,27 @@ class PartieGateway $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); } + public function findOldListePartie() : array{ + $query="SELECT * FROM Partie"; + $this->con->executeQuery($query); + $results = $this->con->getResults(); + $query= "SELECT max(p.id) + FROM PARTIE p;"; + $this->con->executeQuery($query); + $max=$this->con->getResults()[0]; + $listePartie=array(); + foreach($results as $row) + { + $query = "SELECT e.* FROM Enigme e,Contenir c,Partie p + WHERE p.id = c.partie + AND c.enigme = e.id"; + $this->con->executeQuery($query); + $listeEnigme=$this->con->getResults(); + $listePartie=PartieFactory::createPartie($max,$listeEnigme); + } + return $listePartie; + } + public function findOldListeEnigme(string $partie) : array{ $query= "SELECT * FROM Enigme e,Contenir c AND c.partie = :idPartie diff --git a/WEB/Factory/PartieFactory.php b/WEB/Factory/PartieFactory.php index 64f7774b..a581e71a 100644 --- a/WEB/Factory/PartieFactory.php +++ b/WEB/Factory/PartieFactory.php @@ -18,5 +18,4 @@ class PartieFactory{ $partie=new Partie($idMax,$resultsEnigme); return $partie; } - //public static function createListePartie() } \ No newline at end of file diff --git a/WEB/Model/Partie.php b/WEB/Model/Partie.php index c2d66e7c..860f4cf5 100644 --- a/WEB/Model/Partie.php +++ b/WEB/Model/Partie.php @@ -12,7 +12,7 @@ class Partie * @param string $idPartie * @param array $datePartie */ - public function __construct(string $idPartie, array $listeEnigme, array $listeEmailJoueur) + public function __construct(string $idPartie, array $listeEnigme) { $this->idPartie = $idPartie; $this->datePartie = getdate();