modifier mdl et gateway

pull/7/head
Gwenael PLANCHON 1 year ago
parent 5078d4a91a
commit 40af2afbd1

@ -10,9 +10,25 @@ class ScientifiqueGateway
$this->con = $con; $this->con = $con;
} }
public function getRandom(): array|bool{ public function getRandom() {
$this->con->executeQuery( $this->con->executeQuery(
"SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, idsexe FROM Scientifique ORDER BY RANDOM() LIMIT 1;"); "SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, idsexe FROM Scientifique ORDER BY RANDOM() LIMIT 1;");
return $this->con->getOneResult(); 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]
]);
}
} }

@ -17,7 +17,7 @@ class SexeGateway
return $this->con->getOneResult(); return $this->con->getOneResult();
} }
public function getSexes(): array public function getAll(): array
{ {
$this->con->executeQuery("SELECT id, libelle FROM Sexe;"); $this->con->executeQuery("SELECT id, libelle FROM Sexe;");
return $this->con->getResults(); return $this->con->getResults();

@ -16,4 +16,9 @@ class ThematiqueGateway
[':id' => [$id, $this->con::PARAM_INT]]); [':id' => [$id, $this->con::PARAM_INT]]);
return $this->con->getOneResult(); return $this->con->getOneResult();
} }
public function getAll(): array
{
$this->con->executeQuery("SELECT id, libelle FROM Thematique;");
return $this->con->getResults();
}
} }

@ -37,4 +37,7 @@ class MdlScientifique extends MdlBase{
$difficulte, $difficulte,
$sexe); $sexe);
} }
public function addScientifique(Scientifique $s){
return $this->gw->addScientifique($s);
}
} }

@ -14,9 +14,9 @@ class MdlSexe extends MdlBase{
$row = $this->gw->getFromId($id); $row = $this->gw->getFromId($id);
return new Sexe($row['id'], $row['libelle']); return new Sexe($row['id'], $row['libelle']);
} }
public function getSexes(): array { public function getAll(): array {
$ret=array(); $ret=array();
$row = $this->gw->getSexes(); $row = $this->gw->getAll();
for($i=0; $i< count($row); $i++){ for($i=0; $i< count($row); $i++){
array_push($ret, new Sexe($row[$i]['id'], $row[$i]['libelle'])); array_push($ret, new Sexe($row[$i]['id'], $row[$i]['libelle']));
} }

@ -14,4 +14,13 @@ class MdlThematique extends MdlBase{
$row = $this->gw->getFromId($id); $row = $this->gw->getFromId($id);
return new Thematique($row['id'], $row['libelle']); 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;
}
} }
Loading…
Cancel
Save