connection = $connection; } public function getCoach() { $query = "SELECT * FROM Athlete WHERE isCoach = TRUE;"; return $this->connection->executeWithErrorHandling($query); } public function getCoachById(int $userId) { $query = "SELECT * FROM Athlete WHERE idAthlete = :id AND isCoach = TRUE"; $params = [':id' => [$userId, PDO::PARAM_INT]]; return $this->connection->executeWithErrorHandling($query, $params); } public function getCoachByName(string $name) { $query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach = TRUE"; $params = [':name' => [$name, PDO::PARAM_STR]]; return $this->connection->executeWithErrorHandling($query, $params); } public function getCoachByFirstName(string $firstName) { $query = "SELECT * FROM Athlete WHERE prenom = :firstName AND isCoach = TRUE"; $params = [':firstName' => [$firstName, PDO::PARAM_STR]]; return $this->connection->executeWithErrorHandling($query, $params); } public function getCoachByEmail(string $email) { $query = "SELECT * FROM Athlete WHERE email = :email AND isCoach = TRUE"; $params = [':email' => [$email, PDO::PARAM_STR]]; return $this->connection->executeWithErrorHandling($query, $params); } public function getCoachByGender(string $gender) { $query = "SELECT * FROM Athlete WHERE sexe = :gender AND isCoach = TRUE"; $params = [':gender' => [$gender, PDO::PARAM_STR]]; return $this->connection->executeWithErrorHandling($query, $params); } public function getCoachByHeight(int $height) { $query = "SELECT * FROM Athlete WHERE taille = :height AND isCoach = TRUE"; $params = [':height' => [$height, PDO::PARAM_INT]]; return $this->connection->executeWithErrorHandling($query, $params); } public function getCoachByBirthDate(string $birthdate) { $query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate AND isCoach = TRUE"; $params = [':birthdate' => [$birthdate, PDO::PARAM_STR]]; return $this->connection->executeWithErrorHandling($query, $params); } public function addCoach(CoachEntity $coach) { $query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES (:nom, :prenom, :email, :sexe, :taille, :poids, :motDePasse, :dateNaissance, TRUE)"; $params = [ ':nom' => $coach->getNom(), ':prenom' => $coach->getPrenom(), ':email' => $coach->getEmail(), ':sexe' => $coach->getSexe(), ':taille' => $coach->getTaille(), ':poids' => $coach->getPoids(), ':motDePasse' => $coach->getMotDePasse(), ':dateNaissance' => $coach->getDateNaissance(), ]; return $this->connection->executeWithErrorHandling($query, $params); } public function updateCoach(CoachEntity $oldCoach, CoachEntity $newCoach) { $query = "UPDATE Athlete SET nom = :nom, prenom = :prenom, email = :email, sexe = :sexe, taille = :taille, poids = :poids, motDePasse = :motDePasse, dateNaissance = :dateNaissance, isCoach = TRUE WHERE idCoach = :idCoach"; $params = [ ':idAthlete' => $oldCoach->getIdCoach(), ':nom' => $newCoach->getNom(), ':prenom' => $newCoach->getPrenom(), ':email' => $newCoach->getEmail(), ':sexe' => $newCoach->getSexe(), ':taille' => $newCoach->getTaille(), ':poids' => $newCoach->getPoids(), ':motDePasse' => $newCoach->getMotDePasse(), ':dateNaissance' => $newCoach->getDateNaissance(), ]; return $this->connection->executeWithErrorHandling($query, $params); } public function deleteCoach(int $idCoach) { $query = "DELETE FROM Athlete WHERE idAthlete = :idCoach"; $params = [ ':idCoach' => $idCoach, ]; return $this->connection->executeWithErrorHandling($query, $params); } }