Gateway, Entity, Mappeur : Coach, Athlete et Activite
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
8a2736e6ff
commit
c09ce09b26
@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ActivityEntity {
|
||||||
|
private $idActivity;
|
||||||
|
private $type;
|
||||||
|
private $date;
|
||||||
|
private $heureDebut;
|
||||||
|
private $heureFin;
|
||||||
|
private $effortRessenti;
|
||||||
|
private $variabilite;
|
||||||
|
private $variance;
|
||||||
|
private $ecartType;
|
||||||
|
private $moyenne;
|
||||||
|
private $maximum;
|
||||||
|
private $minimum;
|
||||||
|
private $temperatureMoyenne;
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
public function getIdActivity() {
|
||||||
|
return $this->idActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType() {
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDate() {
|
||||||
|
return $this->date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeureDebut() {
|
||||||
|
return $this->heureDebut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeureFin() {
|
||||||
|
return $this->heureFin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEffortRessenti() {
|
||||||
|
return $this->effortRessenti;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVariabilite() {
|
||||||
|
return $this->variabilite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVariance() {
|
||||||
|
return $this->variance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEcartType() {
|
||||||
|
return $this->ecartType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMoyenne() {
|
||||||
|
return $this->moyenne;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaximum() {
|
||||||
|
return $this->maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMinimum() {
|
||||||
|
return $this->minimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemperatureMoyenne() {
|
||||||
|
return $this->temperatureMoyenne;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
public function setIdActivity($idActivity) {
|
||||||
|
$this->idActivity = $idActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType($type) {
|
||||||
|
$this->type = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDate($date) {
|
||||||
|
$this->date = $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeureDebut($heureDebut) {
|
||||||
|
$this->heureDebut = $heureDebut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeureFin($heureFin) {
|
||||||
|
$this->heureFin = $heureFin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEffortRessenti($effortRessenti) {
|
||||||
|
$this->effortRessenti = $effortRessenti;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVariabilite($variabilite) {
|
||||||
|
$this->variabilite = $variabilite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVariance($variance) {
|
||||||
|
$this->variance = $variance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEcartType($ecartType) {
|
||||||
|
$this->ecartType = $ecartType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMoyenne($moyenne) {
|
||||||
|
$this->moyenne = $moyenne;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMaximum($maximum) {
|
||||||
|
$this->maximum = $maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMinimum($minimum) {
|
||||||
|
$this->minimum = $minimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTemperatureMoyenne($temperatureMoyenne) {
|
||||||
|
$this->temperatureMoyenne = $temperatureMoyenne;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ActivityGateway {
|
||||||
|
private $connection;
|
||||||
|
|
||||||
|
public function __construct(Connection $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivity() {
|
||||||
|
$query = "SELECT * FROM Activity";
|
||||||
|
return $this->connection->executeWithErrorHandling($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityById($activityId) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE idActivity = :id";
|
||||||
|
$params = [':id' => [$activityId, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByType($type) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE type = :type";
|
||||||
|
$params = [':type' => [$type, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByDate($date) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE date = :date";
|
||||||
|
$params = [':date' => [$date, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByTimeRange($startTime, $endTime) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE heureDebut >= :startTime AND heureFin <= :endTime";
|
||||||
|
$params = [
|
||||||
|
':startTime' => [$startTime, PDO::PARAM_STR],
|
||||||
|
':endTime' => [$endTime, PDO::PARAM_STR]
|
||||||
|
];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByEffort($effortRessenti) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE effortRessenti = :effort";
|
||||||
|
$params = [':effort' => [$effortRessenti, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByVariability($variabilite) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE variabilite = :variability";
|
||||||
|
$params = [':variability' => [$variabilite, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByTemperature($temperatureMoyenne) {
|
||||||
|
$query = "SELECT * FROM Activity WHERE temperatureMoyenne = :temperature";
|
||||||
|
$params = [':temperature' => [$temperatureMoyenne, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ActiviteMapper {
|
||||||
|
public function map(array $data) {
|
||||||
|
$activite = new ActiviteEntity();
|
||||||
|
$activite->setIdActivite($data['idActivite']);
|
||||||
|
$activite->setType($data['type']);
|
||||||
|
$activite->setDate($data['date']);
|
||||||
|
$activite->setHeureDebut($data['heureDebut']);
|
||||||
|
$activite->setHeureFin($data['heureFin']);
|
||||||
|
$activite->setEffortRessenti($data['effortRessenti']);
|
||||||
|
$activite->setVariabilite($data['variabilite']);
|
||||||
|
$activite->setVariance($data['variance']);
|
||||||
|
$activite->setEcartType($data['ecartType']);
|
||||||
|
$activite->setMoyenne($data['moyenne']);
|
||||||
|
$activite->setMaximum($data['maximum']);
|
||||||
|
$activite->setMinimum($data['minimum']);
|
||||||
|
$activite->setTemperatureMoyenne($data['temperatureMoyenne']);
|
||||||
|
|
||||||
|
return $activite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class AthleteEntity {
|
||||||
|
private $idAthlete;
|
||||||
|
private $nom;
|
||||||
|
private $prenom;
|
||||||
|
private $email;
|
||||||
|
private $sexe;
|
||||||
|
private $taille;
|
||||||
|
private $poids;
|
||||||
|
private $motDePasse;
|
||||||
|
private $dateNaissance;
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
public function getIdAthlete() {
|
||||||
|
return $this->idAthlete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNom() {
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrenom() {
|
||||||
|
return $this->prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail() {
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSexe() {
|
||||||
|
return $this->sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTaille() {
|
||||||
|
return $this->taille;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPoids() {
|
||||||
|
return $this->poids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMotDePasse() {
|
||||||
|
return $this->motDePasse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDateNaissance() {
|
||||||
|
return $this->dateNaissance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
public function setIdAthlete($idAthlete) {
|
||||||
|
$this->idAthlete = $idAthlete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNom($nom) {
|
||||||
|
$this->nom = $nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrenom($prenom) {
|
||||||
|
$this->prenom = $prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail($email) {
|
||||||
|
$this->email = $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSexe($sexe) {
|
||||||
|
$this->sexe = $sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTaille($taille) {
|
||||||
|
$this->taille = $taille;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPoids($poids) {
|
||||||
|
$this->poids = $poids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMotDePasse($motDePasse) {
|
||||||
|
$this->motDePasse = $motDePasse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDateNaissance($dateNaissance) {
|
||||||
|
$this->dateNaissance = $dateNaissance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
class AthleteGateway {
|
||||||
|
private $connection;
|
||||||
|
|
||||||
|
public function __construct(Connection $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthlete() {
|
||||||
|
$query = "SELECT * FROM Athlete";
|
||||||
|
return $this->connection->executeWithErrorHandling($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteById($userId) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE idAthlete = :id";
|
||||||
|
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByName($name) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE nom = :name";
|
||||||
|
$params = [':name' => [$name, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByFirstName($firstName) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE prenom = :firstName";
|
||||||
|
$params = [':firstName' => [$firstName, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByEmail($email) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE email = :email";
|
||||||
|
$params = [':email' => [$email, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByGender($gender) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE sexe = :gender";
|
||||||
|
$params = [':gender' => [$gender, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByHeight($height) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE taille = :height";
|
||||||
|
$params = [':height' => [$height, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByWeight($weight) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE poids = :weight";
|
||||||
|
$params = [':weight' => [$weight, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByBirthDate($birthdate) {
|
||||||
|
$query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate";
|
||||||
|
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Exemple d'utilisation
|
||||||
|
//$dsn = "pgsql:host=localhost;port=5432;dbname=mydatabase;user=myuser;password=mypassword";
|
||||||
|
//$connection = new Connection($dsn);
|
||||||
|
//$gateway = new UserGateway($connection);
|
||||||
|
|
||||||
|
//$allAth = $gateway->getAthlete();
|
||||||
|
//print_r($allAth);
|
||||||
|
|
||||||
|
//$singleAth = $gateway->getAthleteById(1);
|
||||||
|
//print_r($singleAth);
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class AthleteMapper {
|
||||||
|
public function map(array $data) {
|
||||||
|
$athlete = new AthleteEntity();
|
||||||
|
$athlete->setIdAthlete($data['idAthlete']);
|
||||||
|
$athlete->setNom($data['nom']);
|
||||||
|
$athlete->setPrenom($data['prenom']);
|
||||||
|
$athlete->setEmail($data['email']);
|
||||||
|
$athlete->setSexe($data['sexe']);
|
||||||
|
$athlete->setTaille($data['taille']);
|
||||||
|
$athlete->setPoids($data['poids']);
|
||||||
|
$athlete->setMotDePasse($data['motDePasse']);
|
||||||
|
$athlete->setDateNaissance($data['dateNaissance']);
|
||||||
|
|
||||||
|
return $athlete;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class CoachEntity {
|
||||||
|
private $idCoach;
|
||||||
|
private $nom;
|
||||||
|
private $prenom;
|
||||||
|
private $email;
|
||||||
|
private $sexe;
|
||||||
|
private $taille;
|
||||||
|
private $poids;
|
||||||
|
private $motDePasse;
|
||||||
|
private $dateNaissance;
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
public function getIdCoach() {
|
||||||
|
return $this->idCoach;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNom() {
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrenom() {
|
||||||
|
return $this->prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail() {
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSexe() {
|
||||||
|
return $this->sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTaille() {
|
||||||
|
return $this->taille;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPoids() {
|
||||||
|
return $this->poids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMotDePasse() {
|
||||||
|
return $this->motDePasse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDateNaissance() {
|
||||||
|
return $this->dateNaissance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
public function setIdCoach($idCoach) {
|
||||||
|
$this->idCoach = $idCoach;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNom($nom) {
|
||||||
|
$this->nom = $nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrenom($prenom) {
|
||||||
|
$this->prenom = $prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail($email) {
|
||||||
|
$this->email = $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSexe($sexe) {
|
||||||
|
$this->sexe = $sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTaille($taille) {
|
||||||
|
$this->taille = $taille;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPoids($poids) {
|
||||||
|
$this->poids = $poids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMotDePasse($motDePasse) {
|
||||||
|
$this->motDePasse = $motDePasse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDateNaissance($dateNaissance) {
|
||||||
|
$this->dateNaissance = $dateNaissance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
class CoachGateway {
|
||||||
|
private $connection;
|
||||||
|
|
||||||
|
public function __construct(Connection $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoach() {
|
||||||
|
$query = "SELECT * FROM Coach";
|
||||||
|
return $this->connection->executeWithErrorHandling($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoachById($userId) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE idCoach = :id";
|
||||||
|
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoachByName($name) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE nom = :name";
|
||||||
|
$params = [':name' => [$name, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoachByFirstName($firstName) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE prenom = :firstName";
|
||||||
|
$params = [':firstName' => [$firstName, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoachByEmail($email) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE email = :email";
|
||||||
|
$params = [':email' => [$email, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoachByGender($gender) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE sexe = :gender";
|
||||||
|
$params = [':gender' => [$gender, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoachByHeight($height) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE taille = :height";
|
||||||
|
$params = [':height' => [$height, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAthleteByBirthDate($birthdate) {
|
||||||
|
$query = "SELECT * FROM Coach WHERE dateNaissance = :birthdate";
|
||||||
|
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class CoachMapper {
|
||||||
|
public function map(array $data) {
|
||||||
|
$coach = new CoachEntity();
|
||||||
|
$coach->setIdCoach($data['idCoach']);
|
||||||
|
$coach->setNom($data['nom']);
|
||||||
|
$coach->setPrenom($data['prenom']);
|
||||||
|
$coach->setEmail($data['email']);
|
||||||
|
$coach->setSexe($data['sexe']);
|
||||||
|
$coach->setTaille($data['taille']);
|
||||||
|
$coach->setPoids($data['poids']);
|
||||||
|
$coach->setMotDePasse($data['motDePasse']);
|
||||||
|
$coach->setDateNaissance($data['dateNaissance']);
|
||||||
|
|
||||||
|
return $coach;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
class UserGateway {
|
|
||||||
private $connection;
|
|
||||||
|
|
||||||
public function __construct(Connection $connection) {
|
|
||||||
$this->connection = $connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAthlete() {
|
|
||||||
$query = "SELECT * FROM Athlete";
|
|
||||||
return $this->connection->executeWithErrorHandling($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCoach() {
|
|
||||||
$query = "SELECT * FROM Coach";
|
|
||||||
return $this->connection->executeWithErrorHandling($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAthleteById($userId) {
|
|
||||||
$query = "SELECT * FROM Athlete WHERE idAthlete = :id";
|
|
||||||
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCoachById($userId) {
|
|
||||||
$query = "SELECT * FROM Coach WHERE idCoach = :id";
|
|
||||||
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exemple d'utilisation
|
|
||||||
//$dsn = "pgsql:host=localhost;port=5432;dbname=mydatabase;user=myuser;password=mypassword";
|
|
||||||
//$connection = new Connection($dsn);
|
|
||||||
//$gateway = new UserGateway($connection);
|
|
||||||
|
|
||||||
//$allAth = $gateway->getAthlete();
|
|
||||||
//print_r($allAth);
|
|
||||||
|
|
||||||
//$allCoach = $gateway->getCoach();
|
|
||||||
//print_r($allCoach);
|
|
||||||
|
|
||||||
//$singleAth = $gateway->getAthleteById(1);
|
|
||||||
//print_r($singleAth);
|
|
||||||
|
|
||||||
//$singleCoach = $gateway->getCoachById(1);
|
|
||||||
//print_r($singleCoach);
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in new issue