.Get action Set : Get : GetLast : GetAll : .Get note .Get matiere nil nil .Get date .Get matiere */ try { $inst = Config::getInstance(); $bdd = new PDO('mysql:host=' . $inst->get('db_host') . ';dbname=' . $inst->get('db_name') . '', $inst->get('db_user'), $inst->get('db_pass')); } catch (\Exception $e) { die('Erreur : ' . $e->getMessage()); } $bdd->query("SET NAMES 'UTF-8'"); try { if (checkArgument()) { $user = new User($_GET['id'], $_GET['name'], null, null, null); $user->checkIdUser($bdd); $note = new Note(null, $_GET['id'], $_GET['matiere'], $_GET['note'], $_GET['date']); switch ($_GET['action']) { case 'set': $disp = $note->setNote($bdd); break; case 'get': $disp = $note->getNote($bdd); break; case 'getLast': $disp = $note->getLast($bdd); break; case 'getAll': $disp = $note->getAll($bdd); break;
Autoloader::register(); /* ---- VALUE ---- .Get name .Get password */ try { $inst = Config::getInstance(); $bdd = new PDO('mysql:host=' . $inst->get('db_host') . ';dbname=' . $inst->get('db_name') . '', $inst->get('db_user'), $inst->get('db_pass')); } catch (\Exception $e) { die('Erreur : ' . $e->getMessage()); } $bdd->query("SET NAMES 'UTF-8'"); try { if (checkArgument()) { $user = new User(null, $_GET['name'], $_GET['password'], null, null); $user->connectUser($bdd); $disp = array("Status" => "Success", "Name" => $user->getName(), "Password" => $user->getPass(), "Matiere" => $user->getMatiere(), "Roles" => $user->getRoles()); echo json_encode($disp, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); } } catch (Exception $e) { $disp = array("Status" => "Error", "Message" => $e->getMessage(), "Code" => $e->getCode()); echo json_encode($disp, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); } function checkArgument() { $bool = true; $bool = $bool && (isset($_GET['name']) and isset($_GET['password'])); if (!$bool) { throw new Exception('MissingArgument', 03); }