You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.6 KiB
93 lines
2.6 KiB
<?php
|
|
|
|
include 'dal/Gateway/GatewayAbstrait.php';
|
|
|
|
include 'metier/Alumni.php';
|
|
|
|
|
|
class AlumniGateway extends GatewayAbstrait{
|
|
|
|
public function __construct(Connection $con){
|
|
parent::__construct($con);
|
|
}
|
|
|
|
public function insertAlumni(string $mail, string $mdp, string $role){
|
|
try{
|
|
$query='INSERT INTO Alumni(mail,mdp,role) VALUES (:mail, :mdp, :role)';
|
|
$this->con->executeQuery($query, array(
|
|
':mail' => array($mail, PDO::PARAM_STR),
|
|
':mdp' => array($mdp, PDO::PARAM_STR),
|
|
':role' => array($role, PDO::PARAM_STR)
|
|
));
|
|
} catch(PDOException $Exception){
|
|
require 'vues/erreur.html';
|
|
} catch (Exception $Exception){
|
|
require 'vues/erreur.html';
|
|
}
|
|
}
|
|
|
|
public function supprimeAlumni(string $id){
|
|
try{
|
|
$query='DELETE FROM Alumni WHERE id = (:id)';
|
|
$this->con->executeQuery($query, array(
|
|
':id' => array($id, PDO::PARAM_STR),
|
|
));
|
|
} catch(PDOException $Exception){
|
|
require 'vues/erreur.html';
|
|
} catch (Exception $Exception){
|
|
require 'vues/erreur.html';
|
|
}
|
|
}
|
|
|
|
public function modifieMdp(string $id,string $newMdp){
|
|
try{
|
|
$query='UPDATE ALumni SET mdp=(:mdp) WHERE id=(:id)';
|
|
$this->con->executeQuery($query, array(
|
|
':id' => array($id, PDO::PARAM_STR),
|
|
':mdp' => array($newMdp, PDO::PARAM_STR),
|
|
));
|
|
} catch(PDOException $Exception){
|
|
require 'vues/erreur.html';
|
|
} catch (Exception $Exception){
|
|
require 'vues/erreur.html';
|
|
}
|
|
}
|
|
|
|
public function recupereAlumni(string $id){
|
|
try{
|
|
$query='SELECT * FROM Alumni WHERE id=(:id)';
|
|
$this->con->executeQuery($query, array(
|
|
':id' => array($id, PDO::PARAM_STR),
|
|
));
|
|
$res = $this->con->getResults();
|
|
$a=new Alumni($res['id'],$res['mail'],$res['mdp'],$res['role']);
|
|
return $a;
|
|
} catch(PDOException $Exception){
|
|
require 'vues/erreur.html';
|
|
} catch (Exception $Exception){
|
|
require 'vues/erreur.html';
|
|
}
|
|
}
|
|
|
|
public function recupereDataAlumni(){
|
|
try{
|
|
$query='SELECT * FROM Alumni';
|
|
$this->con->executeQuery($query);
|
|
$res = $this->con->getResults();
|
|
$AlumniArray = array();
|
|
foreach($res as $v){
|
|
$a=new Alumni($v['id'],$v['mail'],$v['mdp'],$v['role']);
|
|
array_push($AlumniArray,$a);
|
|
}
|
|
return $AlumniArray;
|
|
} catch(PDOException $Exception){
|
|
require 'vues/erreur.html';
|
|
} catch (Exception $Exception){
|
|
require 'vues/erreur.html';
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|