script d'import dans la BDD

This commit is contained in:
Lucas Mascaro 2015-12-03 12:00:22 +01:00
parent 7bce4e9471
commit 52f588c97d
2 changed files with 23 additions and 0 deletions

View File

@ -23,6 +23,8 @@ class PatientRepo
public function add($civilite,$prenom,$nom,$adresse,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ public function add($civilite,$prenom,$nom,$adresse,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){
$dateNaissance = date('o-m-d',$dateNaissance);
$req = $this->connexion->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)'); $req = $this->connexion->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)');
$result = $req->execute(['civilite' => $civilite, $result = $req->execute(['civilite' => $civilite,
'nom' => $nom, 'nom' => $nom,

21
toBDD.php Normal file
View File

@ -0,0 +1,21 @@
<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 03/12/15
* Time: 11:52
*/
require_once('autoloader.php');
$jsonP = json_decode('Docs/PatientExemple.json',true);
$jsonM = json_decode('Docs/MedecinExemple.json',true);
$repo = new PatientRepo();
foreach($jsonM as $patient) {
$repo->add($patient['Civilite'], $patient['Prenom'], $patient['Nom']);
}
foreach($jsonP as $patient){
$repo->add($patient['Civilite'],$patient['Prenom'],$patient['Nom'],$patient['Adresse'],$patient['Ville'],$patient['CodePostal'],$patient['DateNaissance'],$patient['LieuNaissance'],$patient['NumSecuriteSociale'],$patient['MedecinTraitant'])
}