|
|
|
@ -10,54 +10,70 @@ class CoachGateway {
|
|
|
|
|
$this->connection = $connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoach() {
|
|
|
|
|
public function getCoach(): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach";
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachById(int $userId) {
|
|
|
|
|
public function getCoachById(int $userId): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach WHERE idCoach = :id";
|
|
|
|
|
$params = [':id' => [$userId, PDO::PARAM_INT]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByName(string $name) {
|
|
|
|
|
public function getAthleteByCoachId(int $coachId): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Athlete a, Coach c WHERE a.coachId = :id AND a.isCoach = TRUE";
|
|
|
|
|
$params = [':id' => [$coachId, PDO::PARAM_INT]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByName(string $name): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach c, Athlete a WHERE c.athleteId = a.idAthlete AND a.nom = :name";
|
|
|
|
|
$params = [':name' => [$name, PDO::PARAM_STR]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByFirstName(string $firstName) {
|
|
|
|
|
public function getCoachByFirstName(string $firstName): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach c, Athlete a WHERE c.athleteId = a.idAthlete AND a.prenom = :firstName";
|
|
|
|
|
$params = [':firstName' => [$firstName, PDO::PARAM_STR]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByEmail(string $email) {
|
|
|
|
|
public function getCoachByEmail(string $email): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach c, Athlete a WHERE c.athleteId = a.idAthlete AND a.email = :email";
|
|
|
|
|
$params = [':email' => [$email, PDO::PARAM_STR]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByGender(string $gender) {
|
|
|
|
|
public function getCoachByGender(string $gender): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach c, Athlete a WHERE c.athleteId = a.idAthlete AND a.sexe = :gender";
|
|
|
|
|
$params = [':gender' => [$gender, PDO::PARAM_STR]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByHeight(int $height) {
|
|
|
|
|
public function getCoachByHeight(int $height): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach c, Athlete a WHERE c.athleteId = a.idAthlete AND a.taille = :height";
|
|
|
|
|
$params = [':height' => [$height, PDO::PARAM_INT]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCoachByBirthDate(string $birthdate) {
|
|
|
|
|
public function getCoachByBirthDate(string $birthdate): array
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Coach c, Athlete a WHERE c.athleteId = a.idAthlete AND a.dateNaissance = :birthdate";
|
|
|
|
|
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addCoach(CoachEntity $coach) {
|
|
|
|
|
public function addCoach(CoachEntity $coach): array
|
|
|
|
|
{
|
|
|
|
|
$query = "INSERT INTO Coach (athleteId)
|
|
|
|
|
VALUES (:athleteId)";
|
|
|
|
|
|
|
|
|
@ -68,7 +84,8 @@ class CoachGateway {
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updateCoach(CoachEntity $oldCoach, CoachEntity $newCoach) {
|
|
|
|
|
public function updateCoach(CoachEntity $oldCoach, CoachEntity $newCoach): array
|
|
|
|
|
{
|
|
|
|
|
$query = "UPDATE Coach
|
|
|
|
|
SET athleteId = :athleteId
|
|
|
|
|
WHERE idCoach = :idCoach";
|
|
|
|
@ -81,7 +98,8 @@ class CoachGateway {
|
|
|
|
|
return $this->connection->executeWithErrorHandling($query, $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteCoach(int $idCoach) {
|
|
|
|
|
public function deleteCoach(int $idCoach): array
|
|
|
|
|
{
|
|
|
|
|
$query = "DELETE FROM Coach WHERE idCoach = :idCoach";
|
|
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
|