update paul's branch with database link on search user
continuous-integration/drone/push Build is failing Details

WORK-APE
Antoine PEREDERII 1 year ago
parent d4ee62ce18
commit 15b97837f7

1
.gitignore vendored

@ -6,6 +6,7 @@ dist
*.swo *.swo
.env .env
loginDatabase.php
# Cache file on macOS # Cache file on macOS
.DS_Store .DS_Store

@ -2,6 +2,7 @@
namespace App\Controller; namespace App\Controller;
use Database\AthleteMapper;
use Shared\Validation; use Shared\Validation;
use App\Container; use App\Container;
use App\Router\Request\IRequest; use App\Router\Request\IRequest;
@ -26,38 +27,88 @@ class AthleteController extends BaseController
$this->preference = new Preferences(); $this->preference = new Preferences();
} }
// #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
// public function searchUser(string $username, IRequest $req): Response
// {
// $taberror = [];
// if(!Validation::val_string($username)){
// print("Nom invalide.");
// }
// else {
// try {
// $athleteGateway = new AthleteGateway(new Connexion("mysql:host=localhost;dbname=sae_3", "Perederii", ""));
//// $listSearch=$this->container->get(UserManager::class)->searchUsersByName($username);
// $listSearch = $athleteGateway->getAthlete();
// $map = new AthleteMapper ();
// $athleteEntity = $map->athleteSqlToEntity($listSearch);
// foreach ($athleteEntity as $entity) {
// $users = $map->athleteEntityToModel($entity);
// $listUsers[$i++]=['nom' => $users->getNom(), 'prenom'=>$users->getPrenom(), 'img'=>'john_doe'];
// }
//
// $i=0;
// foreach ($users as $user){
// echo "<h1> HELLO </h1>";
// $listUsers[$i++]=['nom' => $user->getNom(), 'prenom'=>$user->getPrenom(), 'img'=>'john_doe', 'username'=>$user->getUsername()];
// }
// echo "<h1> HEllO </h1>";
// //$currentUser=$this->container->get(UserManager::class)->getCurrentUser();
// //$currentUser=$_SESSION['user'];
// $response = $this->render('./page/addfriend.html.twig',[
// 'css' => $_COOKIE['preferences'],
// 'pp' => "test",
// 'user' => 'johndoe',//$currentUser->getUsername(),
// 'role' => 'Athlete',//$currentUser->getRole(),
// 'users' => $listUsers
// ]);
// } catch (\Throwable $th) {
// throw $th;
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
// }
// }
// return $response;
//
// }
#[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
public function searchUser(string $username, IRequest $req): Response public function searchUser(string $username, IRequest $req): Response
{ {
$taberror = []; $taberror = [];
if(!Validation::val_string($username)){ if (!Validation::val_string($username)) {
print("Nom invalide."); print("Nom invalide.");
} } else {
else {
try { try {
$athleteGateway = new AthleteGateway(new Connexion("mysql:host=londres;dbname=dbkemonteiro2;","kemonteiro2","#Phpmyadmin63")); $athleteGateway = new AthleteGateway(new Connexion("pgsql:host=localhost;dbname=sae_3", "Perederii", ""));
//$listSearch=$this->container->get(UserManager::class)->searchUsersByName($username); $listSearch = $athleteGateway->getAthlete($username);
$listSearch = $athleteGateway->getAthleteByName($username); $map = new AthleteMapper();
$i=0; $athleteEntity = $map->athleteSqlToEntity($listSearch);
foreach ($listSearch as $user){
$listUsers[$i++]=['nom' => $user->getNom(), 'prenom'=>$user->getPrenom(), 'img'=>'john_doe', 'username'=>$user->getUsername()]; $listUsers = [];
$i = 0;
foreach ($athleteEntity as $entity) {
$user = $map->athleteEntityToModel($entity);
$listUsers[$i] = ['idathlete' => number_format($user->getId(), 1), 'nom' => $user->getNom(),
'prenom' => $user->getPrenom(),'email' => $user->getEmail(), 'sexe' => $user->getSexe(),
'taille' => $user->getTaille(), 'poids' => $user->getPoids(), 'motdepasse' => $user->getMotDePasse(),
'datenaissance' => $user->getDateNaissance(), 'iscoach' => $user->getRole(), 'img' => 'test',
'username' => $user->getUsername()];
$i++;
} }
//$currentUser=$this->container->get(UserManager::class)->getCurrentUser();
//$currentUser=$_SESSION['user'];
$response = $this->render('./page/addfriend.html.twig',[ $response = $this->render('./page/addfriend.html.twig',[
'css' => $_COOKIE['preferences'], 'css' => $_COOKIE['preferences'],
'pp' => "test", 'pp' => 'test',
'user' => 'johndoe',//$currentUser->getUsername(), 'user' => 'johndoe',//$currentUser->getUsername(),
'role' => 'Athlete',//$currentUser->getRole(), 'role' => 'Athlete',//$currentUser->getRole(),
'users' => $listUsers 'users' => $listUsers
]); ]);
} catch (\Throwable $th) { } catch (\Throwable $th) {
throw $th; throw $th;
return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); return $this->render("addfriend.html.twig", ['tabError' => $taberror]);
} }
} }
return $response; return $response;
} }
#[Route(path: '/analyses', name: 'analyses', methods: ['GET'])] #[Route(path: '/analyses', name: 'analyses', methods: ['GET'])]

@ -13,7 +13,6 @@ class AthleteEntity {
private $motDePasse; private $motDePasse;
private $dateNaissance; private $dateNaissance;
private $isCoach; private $isCoach;
private $coachId;
// Getters // Getters
public function getIdAthlete() { public function getIdAthlete() {
@ -56,10 +55,6 @@ class AthleteEntity {
return $this->isCoach; return $this->isCoach;
} }
public function getCoachId(){
return $this->coachId;
}
// Setters // Setters
public function setIdAthlete($idAthlete) { public function setIdAthlete($idAthlete) {
$this->idAthlete = $idAthlete; $this->idAthlete = $idAthlete;
@ -100,10 +95,6 @@ class AthleteEntity {
public function setIsCoach($isCoach){ public function setIsCoach($isCoach){
$this->isCoach = $isCoach; $this->isCoach = $isCoach;
} }
public function setCoachId($coachId){
$this->coachId = $coachId;
}
} }
?> ?>

@ -2,6 +2,7 @@
namespace Database; namespace Database;
use \PDO; use \PDO;
use Shared\Log;
class AthleteGateway { class AthleteGateway {
private Connexion $connection; private Connexion $connection;
@ -12,89 +13,72 @@ class AthleteGateway {
public function getAthlete(): array public function getAthlete(): array
{ {
$query = "SELECT * FROM Athlete WHERE isCoach=NULL"; $query = "SELECT * FROM Athlete WHERE isCoach=FALSE";
return $this->connection->executeWithErrorHandling($query); $res = $this->connection->executeWithErrorHandling($query);
return $res;
} }
public function getAthleteById(int $userId): array public function getAthleteById(int $userId): array
{ {
$query = "SELECT * FROM Athlete WHERE idAthlete = :id"; $query = "SELECT * FROM Athlete WHERE idAthlete = :id AND isCoach=FALSE";
$params = [':id' => [$userId, PDO::PARAM_INT]]; $params = [':id' => [$userId, PDO::PARAM_INT]];
return $this->connection->executeWithErrorHandling($query, $params); $res = $this->connection->executeWithErrorHandling($query, $params);
return $res;
} }
public function getAthleteByName(string $name): array public function getAthleteByName(string $name): array
{ {
$query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach=NULL"; $query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach=FALSE";
$params = [':name' => [$name, PDO::PARAM_STR]]; $params = [':name' => [$name, PDO::PARAM_STR]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByFirstName(string $firstName): array public function getAthleteByFirstName(string $firstName): array
{ {
$query = "SELECT * FROM Athlete WHERE prenom = :firstName"; $query = "SELECT * FROM Athlete WHERE prenom = :firstName AND isCoach=FALSE";
$params = [':firstName' => [$firstName, PDO::PARAM_STR]]; $params = [':firstName' => [$firstName, PDO::PARAM_STR]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByEmail(string $email): array public function getAthleteByEmail(string $email): array
{ {
$query = "SELECT * FROM Athlete WHERE email = :email"; $query = "SELECT * FROM Athlete WHERE email = :email AND isCoach=FALSE";
$params = [':email' => [$email, PDO::PARAM_STR]]; $params = [':email' => [$email, PDO::PARAM_STR]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByGender(string $gender): array public function getAthleteByGender(string $gender): array
{ {
$query = "SELECT * FROM Athlete WHERE sexe = :gender"; $query = "SELECT * FROM Athlete WHERE sexe = :gender AND isCoach=FALSE";
$params = [':gender' => [$gender, PDO::PARAM_STR]]; $params = [':gender' => [$gender, PDO::PARAM_STR]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByHeight(int $height): array public function getAthleteByHeight(int $height): array
{ {
$query = "SELECT * FROM Athlete WHERE taille = :height"; $query = "SELECT * FROM Athlete WHERE taille = :height AND isCoach=FALSE";
$params = [':height' => [$height, PDO::PARAM_INT]]; $params = [':height' => [$height, PDO::PARAM_INT]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByWeight(int $weight): array public function getAthleteByWeight(int $weight): array
{ {
$query = "SELECT * FROM Athlete WHERE poids = :weight"; $query = "SELECT * FROM Athlete WHERE poids = :weight AND isCoach=FALSE";
$params = [':weight' => [$weight, PDO::PARAM_INT]]; $params = [':weight' => [$weight, PDO::PARAM_INT]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByBirthDate(string $birthdate): array public function getAthleteByBirthDate(string $birthdate): array
{ {
$query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate"; $query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate AND isCoach=FALSE";
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]]; $params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getAthleteByIsCoachTrue(): array
{
$query = "SELECT * FROM Athlete WHERE isCoach = TRUE";
return $this->connection->executeWithErrorHandling($query);
}
public function getAthleteByIsCoachFalse(): array
{
$query = "SELECT * FROM Athlete WHERE isCoach = FALSE";
return $this->connection->executeWithErrorHandling($query);
}
public function getAthleteByCoachId(int $coachId): array
{
$query = "SELECT * FROM Athlete WHERE coachId = :coachId";
$params = [':coachId' => [$coachId, PDO::PARAM_INT]];
return $this->connection->executeWithErrorHandling($query, $params);
}
public function addAthlete(AthleteEntity $athlete): array public function addAthlete(AthleteEntity $athlete): array
{ {
$query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach, coachId) $query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach)
VALUES (:nom, :prenom, :email, :sexe, :taille, :poids, :motDePasse, :dateNaissance, :isCoach, :coachId)"; VALUES (:nom, :prenom, :email, :sexe, :taille, :poids, :motDePasse, :dateNaissance, :isCoach)";
$params = [ $params = [
':nom' => $athlete->getNom(), ':nom' => $athlete->getNom(),
@ -106,7 +90,6 @@ class AthleteGateway {
':motDePasse' => $athlete->getMotDePasse(), ':motDePasse' => $athlete->getMotDePasse(),
':dateNaissance' => $athlete->getDateNaissance(), ':dateNaissance' => $athlete->getDateNaissance(),
':isCoach' => $athlete->getIsCoach(), ':isCoach' => $athlete->getIsCoach(),
':coachId' => $athlete->getCoachId(),
]; ];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
@ -116,7 +99,7 @@ class AthleteGateway {
{ {
$query = "UPDATE Athlete $query = "UPDATE Athlete
SET nom = :nom, prenom = :prenom, email = :email, sexe = :sexe, SET nom = :nom, prenom = :prenom, email = :email, sexe = :sexe,
taille = :taille, poids = :poids, motDePasse = :motDePasse, dateNaissance = :dateNaissance, isCoach = :isCoach, coachId = :coachId taille = :taille, poids = :poids, motDePasse = :motDePasse, dateNaissance = :dateNaissance, isCoach = :isCoach
WHERE idAthlete = :idAthlete"; WHERE idAthlete = :idAthlete";
$params = [ $params = [
@ -129,8 +112,7 @@ class AthleteGateway {
':poids' => $newAthlete->getPoids(), ':poids' => $newAthlete->getPoids(),
':motDePasse' => $newAthlete->getMotDePasse(), ':motDePasse' => $newAthlete->getMotDePasse(),
':dateNaissance' => $newAthlete->getDateNaissance(), ':dateNaissance' => $newAthlete->getDateNaissance(),
':isCoach' => $athlete->getIsCoach(), ':isCoach' => $newAthlete->getIsCoach(),
':coachId' => $athlete->getCoachId(),
]; ];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);

@ -6,6 +6,7 @@ use \PDO;
use \DateTime; use \DateTime;
use Model\Role; use Model\Role;
use Model\Athlete; use Model\Athlete;
use Shared\Log;
class AthleteMapper { class AthleteMapper {
public function athleteSqlToEntity(array $data): array { public function athleteSqlToEntity(array $data): array {
@ -13,9 +14,8 @@ class AthleteMapper {
foreach ($data as $athleteData) { foreach ($data as $athleteData) {
$athlete = new AthleteEntity(); $athlete = new AthleteEntity();
if (isset($athleteData['idathlete'])) {
if (isset($athleteData['idAthlete'])) { $athlete->setIdAthlete($athleteData['idathlete']);
$athlete->setIdAthlete($athleteData['idAthlete']);
} }
if (isset($athleteData['nom'])) { if (isset($athleteData['nom'])) {
@ -42,18 +42,16 @@ class AthleteMapper {
$athlete->setPoids($athleteData['poids']); $athlete->setPoids($athleteData['poids']);
} }
if (isset($athleteData['motDePasse'])) { if (isset($athleteData['motdepasse'])) {
$athlete->setMotDePasse($athleteData['motDePasse']); $athlete->setMotDePasse($athleteData['motdepasse']);
} }
if (isset($athleteData['dateNaissance'])) { if (isset($athleteData['datenaissance'])) {
$athlete->setDateNaissance($athleteData['dateNaissance']); $athlete->setDateNaissance($athleteData['datenaissance']);
}
if (isset($athleteData['isCoach'])) {
$athlete->setIsCoach($athleteData['isCoach']);
} }
if (isset($athleteData['coachId'])) {
$athlete->setCoachId($athleteData['coachId']); if (isset($athleteData['iscoach'])) {
$athlete->setIsCoach($athleteData['iscoach']);
} }
$athleteEntities[] = $athlete; $athleteEntities[] = $athlete;
@ -64,20 +62,17 @@ class AthleteMapper {
public function athleteEntityToModel(AthleteEntity $athleteEntity): User { public function athleteEntityToModel(AthleteEntity $athleteEntity): User {
$role = new Athlete(); // Utilisez la classe Athlete $role = new Athlete(); // Utilisez la classe Athlete
$date = new DateTime($athleteEntity->getDateNaissance());
$dateSpecific = $athleteEntity->getDateNaissance();
$date = new DateTime($dateSpecific);
$user = new User( $user = new User(
$athleteEntity->getIdAthlete(), $athleteEntity->getIdAthlete(),
$athleteEntity->getNom(), $athleteEntity->getNom(),
$athleteEntity->getPrenom(), $athleteEntity->getPrenom(),
"myUsername",
$athleteEntity->getEmail(), $athleteEntity->getEmail(),
$athleteEntity->getMotDePasse(), $athleteEntity->getMotDePasse(),
$athleteEntity->getSexe(), $athleteEntity->getSexe(),
$athleteEntity->getTaille(), $athleteEntity->getTaille(),
$athleteEntity->getPoids(), $athleteEntity->getPoids(),
$athleteEntity->getDateNaissance(),
$date, $date,
$role $role
); );

@ -2,6 +2,9 @@
namespace Database; namespace Database;
use DateTime;
use Shared\Log;
class Connexion extends \PDO { class Connexion extends \PDO {
private $stmt; private $stmt;
@ -15,13 +18,14 @@ class Connexion extends \PDO {
} }
} }
public function executeQuery(string $query, array $parameters = []): bool { public function executeQuery(string $query, array $parameters = []) {
$this->stmt = $this->prepare($query); $this->stmt = $this->prepare($query);
//foreach ($parameters as $name => $value) { // foreach ($parameters as $name => $value) {
// $this->stmt->bindValue($name, $value[0], $value[1]); // $this->stmt->bindValue($name, $value[0], $value[1]);
//} // }
foreach ($parameters as $name => $value) { foreach ($parameters as $name => $value) {
$bindValueResult = $this->stmt->bindValue($name, $value, \PDO::PARAM_STR); $dataType = is_numeric($value) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
$bindValueResult = $this->stmt->bindValue($name, $value, $dataType);
if (!$bindValueResult) { if (!$bindValueResult) {
// Gérez l'erreur, par exemple, en lançant une exception. // Gérez l'erreur, par exemple, en lançant une exception.
throw new \PDOException('Failed to bind value for parameter ' . $name); throw new \PDOException('Failed to bind value for parameter ' . $name);
@ -43,7 +47,15 @@ class Connexion extends \PDO {
} }
public function getResults(): array { public function getResults(): array {
return $this->stmt->fetchAll(\PDO::FETCH_ASSOC); $results = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
// Convertissez les colonnes "taille" et "poids" en nombres
foreach ($results as &$row) {
$row['taille'] = floatval($row['taille']);
$row['poids'] = floatval($row['poids']);
}
return $results;
} }
} }
?> ?>

@ -1,158 +1,132 @@
-- Athlete Table DROP TABLE IF EXISTS Athlete, Friendship, Notification, Statistique, Entrainement, Participe, SourceDonnee, Activite, FrequenceCardiaque CASCADE;
CREATE TABLE Athlete ( CREATE TABLE Athlete (
idAthlete SERIAL PRIMARY KEY, idAthlete SERIAL PRIMARY KEY,
nom VARCHAR(255), nom VARCHAR(255),
prenom VARCHAR(255), prenom VARCHAR(255),
email VARCHAR(255) UNIQUE, email VARCHAR(255) UNIQUE,
sexe CHAR(1), sexe CHAR(1),
taille DECIMAL, taille DECIMAL,
poids DECIMAL, poids DECIMAL,
motDePasse VARCHAR(255), motDePasse VARCHAR(255),
dateNaissance DATE dateNaissance DATE,
isCoach BOOLEAN
); );
-- Friendship Table
CREATE TABLE Friendship ( CREATE TABLE Friendship (
idAthlete1 INT, idAthlete1 INT,
idAthlete2 INT, idAthlete2 INT,
debut DATE, debut DATE,
PRIMARY KEY (idAthlete1, idAthlete2), PRIMARY KEY (idAthlete1, idAthlete2),
FOREIGN KEY (idAthlete1) REFERENCES Athlete (idAthlete), FOREIGN KEY (idAthlete1) REFERENCES Athlete(idAthlete),
FOREIGN KEY (idAthlete2) REFERENCES Athlete (idAthlete) FOREIGN KEY (idAthlete2) REFERENCES Athlete(idAthlete)
); );
-- Notification Table
CREATE TABLE Notification ( CREATE TABLE Notification (
idNotif SERIAL PRIMARY KEY, idNotif INT PRIMARY KEY,
message TEXT, message TEXT,
date DATE, date DATE,
statut BOOLEAN, statut BOOLEAN,
urgence INT, urgence INT,
athleteId INT, athleteId INT,
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete) FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
);
-- Coach Table
CREATE TABLE Coach (
idCoach SERIAL PRIMARY KEY,
athleteId INT,
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete)
); );
-- Statistique Table
CREATE TABLE Statistique ( CREATE TABLE Statistique (
idStatistique SERIAL PRIMARY KEY, idStatistique INT PRIMARY KEY,
poids DECIMAL, poids DECIMAL,
fcMoyenne DECIMAL, fcMoyenne DECIMAL,
fcMax DECIMAL, fcMax DECIMAL,
caloriesBruleesMoy DECIMAL, caloriesBruleesMoy DECIMAL,
date DATE, date DATE,
athleteId INT, athleteId INT,
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete) FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
); );
-- Entrainement Table
CREATE TABLE Entrainement ( CREATE TABLE Entrainement (
idEntrainement SERIAL PRIMARY KEY, idEntrainement INT PRIMARY KEY,
date DATE, date DATE,
description TEXT, description TEXT,
latitude DECIMAL, latitude DECIMAL,
longitude DECIMAL, longitude DECIMAL,
feedback TEXT, feedback TEXT,
coachId INT, athleteId INT,
FOREIGN KEY (coachId) REFERENCES Coach (idCoach) FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
); );
-- Participe Table
CREATE TABLE Participe ( CREATE TABLE Participe (
athleteId INT, athleteId INT,
entrainementId INT, entrainementId INT,
PRIMARY KEY (athleteId, entrainementId), PRIMARY KEY (athleteId, entrainementId),
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete), FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
FOREIGN KEY (entrainementId) REFERENCES Entrainement (idEntrainement) FOREIGN KEY (entrainementId) REFERENCES Entrainement(idEntrainement)
); );
-- SourceDonnee Table
CREATE TABLE SourceDonnee ( CREATE TABLE SourceDonnee (
idSource SERIAL PRIMARY KEY, idSource INT PRIMARY KEY,
type VARCHAR(255), type VARCHAR(255),
modele VARCHAR(255), modele VARCHAR(255),
precision DECIMAL, precision2 DECIMAL,
athleteId INT, athleteId INT,
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete) FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
); );
-- Activite Table
CREATE TABLE Activite ( CREATE TABLE Activite (
idActivite SERIAL PRIMARY KEY, idActivite INT PRIMARY KEY,
type VARCHAR(255), type VARCHAR(255),
date DATE, date DATE,
heureDeDebut TIME, heureDeDebut TIME,
heureDeFin TIME, heureDeFin TIME,
effortRessent DECIMAL, effortRessent DECIMAL,
variabilite DECIMAL, variabilite DECIMAL,
variance DECIMAL, variance DECIMAL,
ecartType DECIMAL, ecartType DECIMAL,
moyenne DECIMAL, moyenne DECIMAL,
maximum DECIMAL, maximum DECIMAL,
minimum DECIMAL, minimum DECIMAL,
temperatureMoyenne DECIMAL, temperatureMoyenne DECIMAL,
athleteId INT, athleteId INT,
sourceId INT, sourceId INT,
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete), FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
FOREIGN KEY (sourceId) REFERENCES SourceDonnee (idSource) FOREIGN KEY (sourceId) REFERENCES SourceDonnee(idSource)
); );
-- FrequenceCardiaque Table
CREATE TABLE FrequenceCardiaque ( CREATE TABLE FrequenceCardiaque (
idFc SERIAL PRIMARY KEY, idFc INT PRIMARY KEY,
altitude DECIMAL, altitude DECIMAL,
temps TIME, temps TIME,
temperature DECIMAL, temperature DECIMAL,
bpm INT, bpm INT,
longitude DECIMAL, longitude DECIMAL,
latitude DECIMAL, latitude DECIMAL,
activiteId INT, activiteId INT,
FOREIGN KEY (activiteId) REFERENCES Activite (idActivite) FOREIGN KEY (activiteId) REFERENCES Activite(idActivite)
); );
-- Insertion de données dans la table Athlete INSERT INTO Athlete (idAthlete, nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES
INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance) VALUES (1, 'Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01', FALSE),
('Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01'), (2, 'Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02', TRUE);
('Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02');
-- Insertion de données dans la table Friendship
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
(1, 2, '2023-01-01'); (1, 2, '2023-01-01');
-- Insertion de données dans la table Notification
INSERT INTO Notification (message, date, statut, urgence, athleteId) VALUES
('Training session at 10 AM', '2023-03-10', TRUE, 1, 1);
-- Insertion de données dans la table Coach INSERT INTO Notification (idNotif, message, date, statut, urgence, athleteId) VALUES
INSERT INTO Coach (athleteId) VALUES (1, 'Training session at 10 AM', '2023-03-10', TRUE, 1, 1);
(1);
-- Insertion de données dans la table Statistique INSERT INTO Statistique (idStatistique, poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
INSERT INTO Statistique (poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES (1, 70, 80, 150, 500, '2023-03-10', 1);
(70, 80, 150, 500, '2023-03-10', 1);
-- Insertion de données dans la table Entrainement INSERT INTO Entrainement (idEntrainement, date, description, latitude, longitude, feedback, athleteId) VALUES
INSERT INTO Entrainement (date, description, latitude, longitude, feedback, coachId) VALUES (1, '2023-03-12', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1);
('2023-03-12', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1);
-- Insertion de données dans la table Participe
INSERT INTO Participe (athleteId, entrainementId) VALUES INSERT INTO Participe (athleteId, entrainementId) VALUES
(1, 1); (1, 1);
-- Insertion de données dans la table SourceDonnee INSERT INTO SourceDonnee (idSource, type, modele, precision2, athleteId) VALUES
INSERT INTO SourceDonnee (type, modele, precision, athleteId) VALUES (1, 'Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
('Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
-- Insertion de données dans la table Activite INSERT INTO Activite (idActivite, type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
INSERT INTO Activite (type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES (1, 'Running', '2023-03-10', '08:00:00', '09:00:00', 7, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
('Running', '2023-03-10', '08:00:00', '09:00:00', 7, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
-- Insertion de données dans la table FrequenceCardiaque INSERT INTO FrequenceCardiaque (idFc, altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES
INSERT INTO FrequenceCardiaque (altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES (1, 100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);
(100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);

@ -50,7 +50,9 @@ class User {
* @param \DateTime $dateNaissance * @param \DateTime $dateNaissance
* @param \Model\Role $role * @param \Model\Role $role
*/ */
public function __construct(int $id, string $nom, string $prenom, string $username, string $email, string $motDePasse, string $sexe, float $taille, float $poids, \DateTime $dateNaissance, Role $role) public function __construct(int $id, string $nom, string $prenom, string $username, string $email,
string $motDePasse, string $sexe, float $taille, float $poids, \DateTime $dateNaissance,
Role $role)
{ {
$this->id = $id; $this->id = $id;
$this->nom = $nom; $this->nom = $nom;

@ -19,9 +19,7 @@ class GatewayTest extends TestCase {
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp"; //$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;"; require "loginDatabase.php";
$username = "kemonteiro2";
$password = "#Phpmyadmin63";
$connexion = new Connexion($dsn,$username,$password); $connexion = new Connexion($dsn,$username,$password);

@ -0,0 +1,7 @@
<?php
$dsn = "psql:host=localhost;dbname=sae_3;";
$username = "Perederii";
$password = "";
?>
Loading…
Cancel
Save