unification variables de la base

evenements^2
Alexis FERON 1 year ago
parent 803f898499
commit e71d839e33

@ -6,13 +6,9 @@ $rep = __DIR__ . '/php/';
// liste des modules à inclure // liste des modules à inclure
$dConfig['includes']= array('controleur/Validation.php'); $dConfig['includes']= array('controleur/Validation.php');
//BD
$base = 'mysql:host=localhost;dbname=dbAlica';
$login = 'test';
$mdp = 'test';
static $OffersByPage = 5; static $OffersByPage = 5;
// Variables connexion à la base : à modifier en fonction de la base de chacun
define('DB_HOST', 'mysql:host=localhost;dbname=dbAlica'); define('DB_HOST', 'mysql:host=localhost;dbname=dbAlica');
define('DB_USER', 'Dev'); define('DB_USER', 'Dev');
define('DB_PASS', 'Dev'); define('DB_PASS', 'Dev');

@ -10,7 +10,7 @@ class ImageModele
private ImageGateway $gw; private ImageGateway $gw;
public function __construct() public function __construct()
{ {
$this->gw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica","test","test")); $this->gw = new ImageGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
} }
public function publierImage(string $file) : Image public function publierImage(string $file) : Image

@ -18,7 +18,7 @@ class OffreModele
public function __construct() public function __construct()
{ {
$this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); $this->offreGw = new OffreGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
} }
public function publishOffer(string $img, string $logo) public function publishOffer(string $img, string $logo)
@ -86,13 +86,13 @@ class OffreModele
public function CreateOffersFromGw($res) : array public function CreateOffersFromGw($res) : array
{ {
$alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); $alGw = new AlumniGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
$offers=[]; $offers=[];
foreach ($res as $row) foreach ($res as $row)
{ {
$resal = $alGw->ObtenirById($row['offreur']); $resal = $alGw->ObtenirById($row['offreur']);
$profilGw = new ProfilGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "Dev", "Dev")); $profilGw = new ProfilGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
$resProfl = $profilGw->getProfilById($row['offreur']); $resProfl = $profilGw->getProfilById($row['offreur']);
$alumni = new Alumni($resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role'],$resProfl[0]['nom'],$resProfl[0]["prenom"]); $alumni = new Alumni($resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role'],$resProfl[0]['nom'],$resProfl[0]["prenom"]);

@ -21,11 +21,7 @@ class UtilisateurModele
public function connection(string $email, string $mdp) : ? \App\metier\Alumni public function connection(string $email, string $mdp) : ? \App\metier\Alumni
{ {
$dsn = "mysql:host=localhost;dbname=dbAlica"; $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS);
$username = "Dev";
$password = "Dev";
$con = new \App\gateway\Connection($dsn, $username, $password);
$gate = new \App\gateway\AlumniGateway($con); $gate = new \App\gateway\AlumniGateway($con);
// Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway
$utilisateur = $gate->findByEmail($email); $utilisateur = $gate->findByEmail($email);
@ -55,12 +51,8 @@ class UtilisateurModele
public function inscription(string $prenom, string $nom,string $email, string $hashpassword):? \App\metier\Alumni public function inscription(string $prenom, string $nom,string $email, string $hashpassword):? \App\metier\Alumni
{ {
$dsn = "mysql:host=localhost;dbname=dbAlica";
$username = "test";
$password = "test";
$role = "Membre"; $role = "Membre";
$con = new \App\gateway\Connection($dsn, $username, $password); $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS);
$gate = new \App\gateway\AlumniGateway($con); $gate = new \App\gateway\AlumniGateway($con);
$profilGate = new \App\gateway\ProfilGateway($con); $profilGate = new \App\gateway\ProfilGateway($con);
// Insérez le nouvel utilisateur dans la base de données en utilisant AlumniGateway // Insérez le nouvel utilisateur dans la base de données en utilisant AlumniGateway
@ -88,11 +80,7 @@ class UtilisateurModele
public function getUtilisateurByEmail(string $email) public function getUtilisateurByEmail(string $email)
{ {
$dsn = "mysql:host=localhost;dbname=dbAlica"; $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS);
$username = "Dev";
$password = "Dev";
$con = new \App\gateway\Connection($dsn, $username, $password);
$gate = new \App\gateway\AlumniGateway($con); $gate = new \App\gateway\AlumniGateway($con);
// Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway
$utilisateur = $gate->findByEmail($email); $utilisateur = $gate->findByEmail($email);

Loading…
Cancel
Save