diff --git a/project/src/model/gateways/ScientifiqueGateway.php b/project/src/model/gateways/ScientifiqueGateway.php index a863ea2..f3ead18 100644 --- a/project/src/model/gateways/ScientifiqueGateway.php +++ b/project/src/model/gateways/ScientifiqueGateway.php @@ -10,9 +10,25 @@ class ScientifiqueGateway $this->con = $con; } - public function getRandom(): array|bool{ + public function getRandom() { $this->con->executeQuery( "SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, idsexe FROM Scientifique ORDER BY RANDOM() LIMIT 1;"); return $this->con->getOneResult(); } + + public function addScientifique(Scientifique $sci): bool{ + return $this->con->executeQuery( + "INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe) VALUES (:nom, :prenom, :photo, :dateNaissance, :descriptif, :ratioTrouvee, :idThematique, :idDifficulte, :idSexe);" + ,[ + ":nom"=>[$sci->getNom(),$this->con::PARAM_STR], + ":prenom"=>[$sci->getPrenom(),$this->con::PARAM_STR], + ":photo"=>[$sci->getPhoto(),$this->con::PARAM_STR], + ":dateNaissance"=>[date("Y-m-d H:i:s", $sci->getDateNaiss()->getTimestamp()),$this->con::PARAM_STR], + ":descriptif"=>[$sci->getDescriptif(),$this->con::PARAM_STR], + ":ratioTrouvee"=>[$sci->getRatioTrouvee(),$this->con::PARAM_STR], + ":idThematique"=>[$sci->getThematique()->getId(),$this->con::PARAM_STR], + ":idDifficulte"=>[$sci->getDifficulte()->getId(),$this->con::PARAM_STR], + ":idSexe"=>[$sci->getSexe()->getId(),$this->con::PARAM_STR] + ]); + } } \ No newline at end of file diff --git a/project/src/model/gateways/SexeGateway.php b/project/src/model/gateways/SexeGateway.php index f2672cf..833920b 100644 --- a/project/src/model/gateways/SexeGateway.php +++ b/project/src/model/gateways/SexeGateway.php @@ -17,7 +17,7 @@ class SexeGateway return $this->con->getOneResult(); } - public function getSexes(): array + public function getAll(): array { $this->con->executeQuery("SELECT id, libelle FROM Sexe;"); return $this->con->getResults(); diff --git a/project/src/model/gateways/ThematiqueGateway.php b/project/src/model/gateways/ThematiqueGateway.php index deb64cf..59a1166 100644 --- a/project/src/model/gateways/ThematiqueGateway.php +++ b/project/src/model/gateways/ThematiqueGateway.php @@ -16,4 +16,9 @@ class ThematiqueGateway [':id' => [$id, $this->con::PARAM_INT]]); return $this->con->getOneResult(); } + public function getAll(): array + { + $this->con->executeQuery("SELECT id, libelle FROM Thematique;"); + return $this->con->getResults(); + } } \ No newline at end of file diff --git a/project/src/model/mdl/MdlScientifique.php b/project/src/model/mdl/MdlScientifique.php index 6ea01da..2e3aa9f 100644 --- a/project/src/model/mdl/MdlScientifique.php +++ b/project/src/model/mdl/MdlScientifique.php @@ -37,4 +37,7 @@ class MdlScientifique extends MdlBase{ $difficulte, $sexe); } + public function addScientifique(Scientifique $s){ + return $this->gw->addScientifique($s); + } } \ No newline at end of file diff --git a/project/src/model/mdl/MdlSexe.php b/project/src/model/mdl/MdlSexe.php index 0bb7362..beaf9d8 100644 --- a/project/src/model/mdl/MdlSexe.php +++ b/project/src/model/mdl/MdlSexe.php @@ -14,9 +14,9 @@ class MdlSexe extends MdlBase{ $row = $this->gw->getFromId($id); return new Sexe($row['id'], $row['libelle']); } - public function getSexes(): array { + public function getAll(): array { $ret=array(); - $row = $this->gw->getSexes(); + $row = $this->gw->getAll(); for($i=0; $i< count($row); $i++){ array_push($ret, new Sexe($row[$i]['id'], $row[$i]['libelle'])); } diff --git a/project/src/model/mdl/MdlThematique.php b/project/src/model/mdl/MdlThematique.php index d09f2ca..e477104 100644 --- a/project/src/model/mdl/MdlThematique.php +++ b/project/src/model/mdl/MdlThematique.php @@ -14,4 +14,13 @@ class MdlThematique extends MdlBase{ $row = $this->gw->getFromId($id); return new Thematique($row['id'], $row['libelle']); } + + public function getAll(): array { + $ret=array(); + $row = $this->gw->getAll(); + for($i=0; $i< count($row); $i++){ + array_push($ret, new Thematique($row[$i]['id'], $row[$i]['libelle'])); + } + return $ret; + } } \ No newline at end of file