Mise en place de la base de donnée

ServeurDeTest
Johan LACHENAL 2 years ago
parent 2f34912b89
commit 2eab5349c9

@ -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

@ -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;
}
/**

@ -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)

Loading…
Cancel
Save