2015-12-02 12:31:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: seekdasky
|
|
|
|
* Date: 02/12/15
|
|
|
|
* Time: 12:36
|
|
|
|
*/
|
|
|
|
class MedecinRepo
|
|
|
|
{
|
|
|
|
private $connexion;
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
$this->connexion = StaticRepo::getConnexion();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getById($id){
|
|
|
|
$req = $this->connexion->prepare('SELECT * FROM Medecin WHERE Id = :id');
|
|
|
|
$req->execute(['id' => $id]);
|
|
|
|
return $req->fetchAll();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function add($civilite,$prenom,$nom){
|
2015-12-03 09:43:27 +00:00
|
|
|
$req = $this->connexion->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
|
|
|
|
$result = $req->execute(['civilite' => $civilite,
|
|
|
|
'nom' => $nom,
|
2015-12-03 10:50:53 +00:00
|
|
|
'prenom' => $prenom]);
|
2015-12-03 09:43:27 +00:00
|
|
|
if($result){return ['id' => $this->connexion->lastInsertId()];}
|
|
|
|
else{return false;}
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
2015-12-03 09:43:27 +00:00
|
|
|
public function delete($idMedecin){
|
|
|
|
$req = $this->connexion->prepare('DELETE FROM Medecin WHERE Id = :id');
|
|
|
|
return $req->execute(['id' => $idMedecin]);
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function search($nom,$prenom){
|
2015-12-03 09:43:27 +00:00
|
|
|
$req = $this->connexion->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
|
|
|
|
$req->execute(['nom' => $nom,
|
|
|
|
'prenom' => $prenom]);
|
2015-12-02 12:31:37 +00:00
|
|
|
|
2015-12-03 09:43:27 +00:00
|
|
|
return StaticRepo::delNumeric($req->fetchAll());
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPatients($idMedecin){
|
|
|
|
|
2015-12-03 09:43:27 +00:00
|
|
|
$req = $this->connexion->prepare('SELECT Patient.* FROM Patient,Medecin
|
|
|
|
WHERE Medecin.Id = :id
|
|
|
|
AND Medecin.Id = Patient.MedecinTraitant');
|
|
|
|
|
|
|
|
$req->execute(['id' => $idMedecin]);
|
|
|
|
return StaticRepo::delNumeric($req->fetchAll());
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
2015-12-03 09:43:27 +00:00
|
|
|
}
|