Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
33.33% |
2 / 6 |
CRAP | |
46.43% |
13 / 28 |
RDVRepo | |
0.00% |
0 / 1 |
|
33.33% |
2 / 6 |
14.53 | |
46.43% |
13 / 28 |
getById | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
getByDate | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
delete | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
add | |
0.00% |
0 / 1 |
2.01 | |
88.89% |
8 / 9 |
|||
updateDateTime | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
getByPatientAndDate | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
<?php | |
/** | |
* Created by PhpStorm. | |
* User: seekdasky | |
* Date: 02/12/15 | |
* Time: 12:36 | |
*/ | |
class RDVRepo | |
{ | |
public static function getById($id){ | |
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Id = :id'); | |
$req->execute(['id' => $id]); | |
return StaticRepo::delNumeric( $req->fetch(), true ); | |
} | |
public static function getByDate($date){ | |
$date = strtotime($date); | |
$date = date('o-m-d',$date); | |
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(DateRDV)) = :date'); | |
$req->execute(['date' => $date]); | |
return StaticRepo::delNumeric($req->fetchAll()); | |
} | |
public static function delete($idRDV){ | |
$req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE Id = :id'); | |
return $req->execute(['id' => $idRDV]); | |
} | |
public static function add($date,$duree,$idPatient,$idMedecin){ | |
$date = date('Y-m-d H:i:s',strtotime($date)); | |
$duree = date('H:i:s',$duree*60); | |
$req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); | |
$result = $req->execute(['date' => $date, | |
'duree' => $duree, | |
'patient' => $idPatient, | |
'medecin' => $idMedecin]); | |
if($result != false){return StaticRepo::getConnexion()->lastInsertId();} | |
else{return false;} | |
} | |
public static function updateDateTime($idRDV,$dateTime){ | |
$date = strtotime($dateTime); | |
$req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); | |
return $req->execute(['date' => $date, | |
'id' => $idRDV]); | |
} | |
public static function getByPatientAndDate($idPatient,$date){ | |
$date = strtotime($date); | |
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DateRDV=:date'); | |
$req->execute(['patient' => $idPatient, | |
'date' => $date]); | |
return StaticRepo::delNumeric($req->fetchAll()); | |
} | |
} |