diff --git a/Sources/src/app/controller/AthleteController.php b/Sources/src/app/controller/AthleteController.php index 0abf76a2..6f37a675 100644 --- a/Sources/src/app/controller/AthleteController.php +++ b/Sources/src/app/controller/AthleteController.php @@ -90,7 +90,11 @@ class AthleteController extends BaseController } else { try { $athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD)); - $listSearch = $athleteGateway->getAthlete($username); + if($username==null){ + $listSearch=$athleteGateway->getAthlete(); + } else { + $listSearch = $athleteGateway->getAthleteByName($username); + } $map = new AthleteMapper(); $athleteEntity = $map->athleteSqlToEntity($listSearch); $listUsers = []; diff --git a/Sources/src/data/core/database/AthleteGateway.php b/Sources/src/data/core/database/AthleteGateway.php index 22a78fbd..323be996 100644 --- a/Sources/src/data/core/database/AthleteGateway.php +++ b/Sources/src/data/core/database/AthleteGateway.php @@ -30,7 +30,7 @@ class AthleteGateway { public function getAthleteByName(string $name): array { $query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach=FALSE"; - $params = [':name' => [$name, PDO::PARAM_STR]]; + $params = [':name' => $name]; return $this->connection->executeWithErrorHandling($query, $params); }