Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
83.33% covered (warning)
83.33%
5 / 6
CRAP
95.24% covered (success)
95.24%
20 / 21
MedecinRepo
0.00% covered (danger)
0.00%
0 / 1
83.33% covered (warning)
83.33%
5 / 6
7
95.24% covered (success)
95.24%
20 / 21
 getById
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 add
0.00% covered (danger)
0.00%
0 / 1
2.02
83.33% covered (warning)
83.33%
5 / 6
 delete
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 search
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 getPatients
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 getAll
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?php
/**
 * Created by PhpStorm.
 * User: seekdasky
 * Date: 02/12/15
 * Time: 12:36
 */
class MedecinRepo
{
    public static function getById($id){
        $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id');
        $req->execute(['id' => $id]);
        return StaticRepo::delNumeric( $req->fetch(), true );
    }
    public static function add($civilite,$prenom,$nom){
        $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
        $result = $req->execute(['civilite' => $civilite,
            'nom' => $nom,
            'prenom' => $prenom]);
        if($result != false){return StaticRepo::getConnexion()->lastInsertId();}
        else{return false;}
    }
    public static function delete($idMedecin){
        $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id');
        return $req->execute(['id' => $idMedecin]);
    }
    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]);
        return StaticRepo::delNumeric($req->fetchAll());
    }
    public static function getPatients($idMedecin){
        $req = StaticRepo::getConnexion()->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() );
    }
}