Ejemplo n.º 1
0
 public static function testUpdate($dbh)
 {
     try {
         $u = Utilisateur::updateUtilisateur($dbh, $_POST["nom"], $_POST["prenom"], $_POST["identifiant"], $_POST["motdepasse"]);
         if (is_array($u) && isset($u["error"])) {
             return json_encode($u);
         } else {
             return json_encode(array("result" => json_decode(json_encode($u))));
         }
     } catch (PDOException $e) {
         if ($e->getCode() == 23000) {
             return json_encode(array('error' => array('identifiant' => "Identifiant déjà pris")));
         } else {
             return json_encode(array('error' => array('identifiant' => "Autre erreur BDD")));
         }
     } catch (Exception $e) {
         echo json_encode(array('error' => array('nom' => $e->getCode())));
     }
 }