Example #1
0
 public function addPharmacie(Pharmacie $pharmacie)
 {
     global $pdo;
     try {
         //On ajoute la pharmacie dans la table tab_pharmacie
         $query = "INSERT INTO tab_pharmacie\n            SET\n            nom =            :nom,\n            adresse =        :adresse,\n            ville =          :ville,\n            contact =        :contact,\n            quartier =       :quartier,\n            numero =         :numero";
         $q = $pdo->prepare($query);
         $q->bindValue(':nom', $pharmacie->getNom());
         $q->bindValue(':adresse', $pharmacie->getAdresse());
         $q->bindValue(':ville', $pharmacie->getVille());
         $q->bindValue(':contact', $pharmacie->getContact());
         $q->bindValue(':quartier', $pharmacie->getQuartier());
         $q->bindValue(':numero', $pharmacie->getNumero());
         $q->execute();
         $pharmaIdAdd = $pdo->lastInsertId();
         return $pharmaIdAdd;
     } catch (PDOException $e) {
         return $e->getMessage();
     }
 }
Example #2
0
<?php

include_once 'Pharmacie.php';
include_once 'PharmacieDao.php';
$nom = filter_input(INPUT_POST, 'nom', FILTER_SANITIZE_STRING);
$adresse = filter_input(INPUT_POST, 'adresse', FILTER_SANITIZE_STRING);
$ville = filter_input(INPUT_POST, 'ville', FILTER_SANITIZE_STRING);
$contact = filter_input(INPUT_POST, 'contact', FILTER_SANITIZE_STRING);
$quartier = filter_input(INPUT_POST, 'quartier', FILTER_SANITIZE_STRING);
$numero = filter_input(INPUT_POST, 'numero', FILTER_SANITIZE_STRING);
if ($nom != "" || $adresse != "" || $ville != "" || $quartier) {
    $pharma = new Pharmacie();
    $pharma->setNom($nom);
    $pharma->setAdresse($adresse);
    $pharma->setVille($ville);
    $pharma->setContact($contact);
    $pharma->setQuartier($quartier);
    $pharma->setNumero($numero);
    echo 'Nom: ' + $pharma->getNom();
    $dao = new PharmaciesDao();
    $_pharmaId = $dao->addPharmacie($pharma);
    if ($_pharmaId > 0) {
        $result = array("message" => "Pharmacie ajouter avec succès");
        //json_encode($result);
    }
}