diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index ce9b335..d5fadef 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -20,10 +20,11 @@ class StudentController try{ $action = $_REQUEST['action']?? null; switch($action) { - case NULL: + case "AllVocab": + affAllVocab(); break; - case "ajouter": - ajouter($_REQUEST['']); + case "getByName": + getByName(); break; default: @@ -43,7 +44,7 @@ class StudentController require($dataVueEreur['erreur']); } } - function AffAllStudent():void{ + public function affAllVocab():void{ global $twig; $mdl = new MdlStudent(); $student = $mdl->getAll(); @@ -51,5 +52,14 @@ class StudentController } + public function getByName($name):void{ + global $twig; + $mdl = new MdlStudent(); + $vocab = $mdl->getVocabByName($name); + echo $twig->render('usersView.html', ['users'=> $vocab]); + + } + + } diff --git a/Project/php/gateway/VocabularyGateway.php b/Project/php/gateway/VocabularyGateway.php index 1120b97..4aee47e 100755 --- a/Project/php/gateway/VocabularyGateway.php +++ b/Project/php/gateway/VocabularyGateway.php @@ -28,7 +28,7 @@ class VocabularyGateway extends AbsGateway } } - public function remove(array $id): void + public function remove(int $id): void { try{ $query = "DELETE FROM Vocabulary v WHERE v.id=:id "; diff --git a/Project/php/model/MdlStudent.php b/Project/php/model/MdlStudent.php index 4d7e482..d93b3c1 100755 --- a/Project/php/model/MdlStudent.php +++ b/Project/php/model/MdlStudent.php @@ -26,7 +26,7 @@ class MdlStudent extends AbsModel else return null; } */ - public function getAll(){ + public function getAll():array{ global $twig; $gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); return $gtw->findAll(); @@ -38,14 +38,16 @@ class MdlStudent extends AbsModel */ } - public function getById($id){ - $gtw = new VocabularyGateway(new Connection()); - $res = $gtw->getById($id); + public function getVocabByName($name):array{ + $gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); + $res = $gtw->findByName($name); return $res; } + + }