parent
e64f991bd4
commit
9a2ca2e3ba
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class ScientifiqueGateway
|
||||||
|
{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRandom(): array|bool{
|
||||||
|
$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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace model;
|
|
||||||
|
|
||||||
class ScientistGateway
|
|
||||||
{
|
|
||||||
private $con;
|
|
||||||
|
|
||||||
function __construct(Connection $co) {
|
|
||||||
$this->con = $co;
|
|
||||||
}
|
|
||||||
|
|
||||||
// function findByName(string $name) :? Scientist {
|
|
||||||
// $usr = null;
|
|
||||||
// }
|
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class MdlScientifique extends MdlBase{
|
||||||
|
private ScientifiqueGateway $gw;
|
||||||
|
private MdlSexe $mdlSexe;
|
||||||
|
private MdlDifficulte $mdlDifficulte;
|
||||||
|
private MdlThematique $mdlThematique;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->gw = new ScientifiqueGateway($this->con);
|
||||||
|
$this->mdlSexe = new MdlSexe();
|
||||||
|
$this->mdlDifficulte = new MdlDifficulte();
|
||||||
|
$this->mdlThematique = new MdlThematique();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRandom(): Scientifique{
|
||||||
|
$row = $this->gw->getRandom();
|
||||||
|
if($row == false) throw new RuntimeException("Erreur aucun scientifique trouvé");
|
||||||
|
$sexe = $this->mdlSexe->getFromId($row['idsexe']);
|
||||||
|
$difficulte = $this->mdlDifficulte->getFromId($row['iddifficulte']);
|
||||||
|
$thematique = $this->mdlThematique->getFromId($row['idthematique']);
|
||||||
|
|
||||||
|
return new Scientifique($row['id'],
|
||||||
|
$row['nom'],
|
||||||
|
$row['prenom'],
|
||||||
|
$row['photo'],
|
||||||
|
new DateTime($row['datenaissance']),
|
||||||
|
$row['descriptif'],
|
||||||
|
$row['ratiotrouvee'],
|
||||||
|
$thematique,
|
||||||
|
$difficulte,
|
||||||
|
$sexe);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
class Scientifique
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $nom;
|
||||||
|
private string $prenom;
|
||||||
|
private string $photo;
|
||||||
|
private DateTime $dateNaiss;
|
||||||
|
private string $descriptif;
|
||||||
|
private float $ratioTrouvee;
|
||||||
|
private Thematique $thematique;
|
||||||
|
private Difficulte $difficulte;
|
||||||
|
private Sexe $sexe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @param string $nom
|
||||||
|
* @param string $prenom
|
||||||
|
* @param string $photo
|
||||||
|
* @param string $descriptif
|
||||||
|
* @param Thematique $thematique
|
||||||
|
* @param Difficulte $difficulte
|
||||||
|
* @param Sexe $sexe
|
||||||
|
*/
|
||||||
|
public function __construct(int $id,
|
||||||
|
string $nom,
|
||||||
|
string $prenom,
|
||||||
|
string $photo,
|
||||||
|
DateTime $dateNaiss,
|
||||||
|
string $descriptif,
|
||||||
|
float $ratioTrouvee,
|
||||||
|
Thematique $thematique,
|
||||||
|
Difficulte $difficulte,
|
||||||
|
Sexe $sexe)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->nom = $nom;
|
||||||
|
$this->prenom = $prenom;
|
||||||
|
$this->photo = $photo;
|
||||||
|
$this->ratioTrouvee = $ratioTrouvee;
|
||||||
|
$this->descriptif = $descriptif;
|
||||||
|
$this->dateNaiss = $dateNaiss;
|
||||||
|
$this->thematique = $thematique;
|
||||||
|
$this->difficulte = $difficulte;
|
||||||
|
$this->sexe = $sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNom(): string
|
||||||
|
{
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPrenom(): string
|
||||||
|
{
|
||||||
|
return $this->prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPhoto(): string
|
||||||
|
{
|
||||||
|
return $this->photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescriptif(): string
|
||||||
|
{
|
||||||
|
return $this->descriptif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return DateTime
|
||||||
|
*/
|
||||||
|
public function getDateNaiss(): DateTime
|
||||||
|
{
|
||||||
|
return $this->dateNaiss;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getRatioTrouvee(): float
|
||||||
|
{
|
||||||
|
return $this->ratioTrouvee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Thematique
|
||||||
|
*/
|
||||||
|
public function getThematique(): Thematique
|
||||||
|
{
|
||||||
|
return $this->thematique;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Difficulte
|
||||||
|
*/
|
||||||
|
public function getDifficulte(): Difficulte
|
||||||
|
{
|
||||||
|
return $this->difficulte;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue