2015-12-02 12:31:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: seekdasky
|
|
|
|
* Date: 02/12/15
|
|
|
|
* Time: 12:36
|
|
|
|
*/
|
|
|
|
class MedecinRepo
|
|
|
|
{
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
public static function getById($id){
|
2015-12-10 09:56:06 +00:00
|
|
|
|
|
|
|
if(!StaticRepo::checkParam($id,'Integer')){return false;}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id');
|
2015-12-02 12:31:37 +00:00
|
|
|
$req->execute(['id' => $id]);
|
2015-12-08 08:31:47 +00:00
|
|
|
return StaticRepo::delNumeric( $req->fetch(), true );
|
2015-12-02 12:31:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
public static function add($civilite,$prenom,$nom){
|
2015-12-10 09:56:06 +00:00
|
|
|
|
|
|
|
if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
$req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
|
2015-12-03 09:43:27 +00:00
|
|
|
$result = $req->execute(['civilite' => $civilite,
|
2015-12-08 08:31:47 +00:00
|
|
|
'nom' => $nom,
|
|
|
|
'prenom' => $prenom]);
|
|
|
|
if($result != false){return StaticRepo::getConnexion()->lastInsertId();}
|
|
|
|
else{return false;}
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
public static function delete($idMedecin){
|
|
|
|
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id');
|
|
|
|
return $req->execute(['id' => $idMedecin]);
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
public static function search($nom,$prenom){
|
|
|
|
$req = StaticRepo::getConnexion()->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-08 08:31:47 +00:00
|
|
|
return StaticRepo::delNumeric($req->fetchAll());
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
public static function getPatients($idMedecin){
|
2015-12-02 12:31:37 +00:00
|
|
|
|
2015-12-10 09:56:06 +00:00
|
|
|
if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
$req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin
|
2015-12-03 09:43:27 +00:00
|
|
|
WHERE Medecin.Id = :id
|
|
|
|
AND Medecin.Id = Patient.MedecinTraitant');
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
$req->execute(['id' => $idMedecin]);
|
|
|
|
return StaticRepo::delNumeric($req->fetchAll());
|
2015-12-02 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 07:50:30 +00:00
|
|
|
public static function getAll(){
|
|
|
|
|
|
|
|
$req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC');
|
|
|
|
|
|
|
|
return StaticRepo::delNumeric( $req->fetchAll() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-03 09:43:27 +00:00
|
|
|
}
|