65 lines
1.7 KiB
PHP
Executable File
65 lines
1.7 KiB
PHP
Executable File
<?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){
|
|
$req = $this->connexion->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
|
|
$result = $req->execute(['civilite' => $civilite,
|
|
'nom' => $nom,
|
|
'prenom' => $prenom]);
|
|
if($result){return ['id' => $this->connexion->lastInsertId()];}
|
|
else{return false;}
|
|
}
|
|
|
|
public function delete($idMedecin){
|
|
$req = $this->connexion->prepare('DELETE FROM Medecin WHERE Id = :id');
|
|
return $req->execute(['id' => $idMedecin]);
|
|
}
|
|
|
|
public function search($nom,$prenom){
|
|
$req = $this->connexion->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
|
|
$req->execute(['nom' => $nom,
|
|
'prenom' => $prenom]);
|
|
|
|
return StaticRepo::delNumeric($req->fetchAll());
|
|
}
|
|
|
|
public function getPatients($idMedecin){
|
|
|
|
$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());
|
|
}
|
|
|
|
public static function getAll(){
|
|
|
|
$req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC');
|
|
|
|
return StaticRepo::delNumeric( $req->fetchAll() );
|
|
|
|
}
|
|
|
|
}
|