diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 03a33c31..2da39537 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -25,9 +25,9 @@ class EnigmeGateway public function insert(Enigme $enigme) { - $query = "INSERT INTO Enigme VALUES (:idEnigme,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution)"; + $query = "INSERT INTO Enigme VALUES (:id,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution)"; $this->con->executeQuery($query, array( - ':idEnigme' => array($enigme->getIdEnigme(), PDO::PARAM_STR), + ':id' => array($enigme->getIdEnigme(), PDO::PARAM_STR), ':admin' => array($enigme->getAdmin(), PDO::PARAM_STR), ':enonce' => array($enigme->getEnonce(), PDO::PARAM_STR), ':aide' => array($enigme->getAide(), PDO::PARAM_STR), @@ -49,9 +49,15 @@ class EnigmeGateway public function findById(string $idEnigme) { $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; - $this->con->executequery($query,array( + $this->con->executequery($query,array( ':idEnigme' => array($idEnigme,PDO::PARAM_STR) - )); + )); + $results=$this->con->getResults(); + $tabEnigme=array(); + /*foreach ($results as row) + { + $tabEnigme[]= new Enigme(row['id'],row['']); + }*/ } public function showAll(): void diff --git a/WEB/Model/Enigme.php b/WEB/Model/Enigme.php index d14528ec..3f023f92 100644 --- a/WEB/Model/Enigme.php +++ b/WEB/Model/Enigme.php @@ -5,6 +5,7 @@ class Enigme private string $idEnigme; private string $enonce; private string $aide; + private string $admin; private string $rappel; private string $solution; private string $test; @@ -19,7 +20,7 @@ class Enigme * @param string $test * @param int $tempsDeResolution */ - public function __construct(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test, int $tempsDeResolution) + public function __construct() { $arguments=func_get_args(); $index=func_num_args(); @@ -27,21 +28,42 @@ class Enigme call_user_func(array(array($this,$function),$arguments)); } - public function __constructMulti(string $idEnigme, string $enonce, string $solution, string $test, int $tempsDeResolution){ + public function __constructMulti(string $idEnigme, string $enonce, string $solution, string $test, int $tempsDeResolution,string $admin){ $this->idEnigme=$idEnigme; $this->enonce=$enonce; $this->solution=$solution; $this->test=$test; $this->tempsDeResolution=$tempsDeResolution; + $this->aide=NULL; + $this->rappel=NULL; + $this->admin=$admin; } - public function __constructSolo(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test){ + public function __constructSolo(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test,string $admin){ $this->idEnigme=$idEnigme; $this->enonce=$enonce; $this->aide=$aide; $this->rappel=$rappel; $this->solution=$solution; $this->test=$test; + $this->tempsDeResolution=0; + $this->admin=$admin; + } + + /** + * @return string + */ + public function getAdmin(): string + { + return $this->admin; + } + + /** + * @param string $admin + */ + public function setAdmin(string $admin): void + { + $this->admin = $admin; } /** diff --git a/WEB/Model/bd.sql b/WEB/Model/bd.sql index 69c86116..667225ff 100644 --- a/WEB/Model/bd.sql +++ b/WEB/Model/bd.sql @@ -36,7 +36,7 @@ test varchar(250) NOT NULL, tempsDeResolution numeric CHECK (tempsDeResolution >0) ); -CREATE TABLE Game( +CREATE TABLE Partie( id char(5) PRIMARY KEY ); @@ -49,7 +49,7 @@ PRIMARY KEY(joueur, enigme) CREATE TABLE ResoudreEnMulti( joueur varchar(50) REFERENCES Joueur(email), -enigme varchar(5) REFERENCES Enigme(id), +enigme char(5) REFERENCES Enigme(id), partie char(5) REFERENCES Partie(id), indexEnigme numeric UNIQUE, PRIMARY KEY(joueur, enigme, partie)