diff --git a/Project/php/model/Teacher.php b/Project/php/model/Teacher.php index 5b5820d..3f4a494 100755 --- a/Project/php/model/Teacher.php +++ b/Project/php/model/Teacher.php @@ -1,7 +1,6 @@ "eng" - ); protected String $name; protected String $image; /** - * @param string[] $map * @param String $name * @param String $image */ - public function __construct(array $map, $name, $image) + public function __construct( $name, $image) { - $this->map = $map; $this->name = $name; $this->image = $image; } -/* - public function translateToEnglish($fr) { - return isset($this->map[$fr]) ? $this->map[$fr] : $fr; + public function __toString(): string + { + return "Vocabulaire :" . $this->name . $this->image; } - public function translateToFrench($eng) { - // Chercher la clé correspondante pour la valeur en anglais - $key = array_search($eng, $this->map); + /* + public function translateToEnglish($fr) { + return isset($this->map[$fr]) ? $this->map[$fr] : $fr; + } - // Si la traduction est trouvée, retourner la clé (en français) - return $key !== false ? $key : $eng; - } + public function translateToFrench($eng) { + // Chercher la clé correspondante pour la valeur en anglais + $key = array_search($eng, $this->map); + + // Si la traduction est trouvée, retourner la clé (en français) + return $key !== false ? $key : $eng; + } + + public function addTranslation($fr, $eng) { + $this->map[$fr] = $eng; + } + */ - public function addTranslation($fr, $eng) { - $this->map[$fr] = $eng; - } -*/ - /** - * @return string[] - */ - public function getMap() - { - return $this->map; - } /** * @return String @@ -64,13 +58,6 @@ class Vocabulary return $this->image; } - /** - * @param string[] $map - */ - public function setMap($map) - { - $this->map = $map; - } /** * @param String $nom diff --git a/Project/php/model/VocabularyGateway.php b/Project/php/model/VocabularyGateway.php old mode 100644 new mode 100755 index 5d56341..f224de1 --- a/Project/php/model/VocabularyGateway.php +++ b/Project/php/model/VocabularyGateway.php @@ -1,8 +1,41 @@ con = $con; + } + + + public function findByName(String $name){ + try{ + + $query = "SELECT * FROM Vocabulary v WHERE v.name=:name"; + $args = array(':name'=>array($name,PDO::PARAM_STR)); + $this->con->ExecuteQuery($query,$args); + + $res = $this->con->getResults(); + $tab_vocab=[]; + foreach($res as $r){ + $tab_vocab[]=new Vocabulary($r['id'],$r['name'],$r['image']); + } + Return $tab_vocab; + } + + catch(PDOException $e ){ + error_log('PDOException: ' . $e->getMessage(), 3, 'error.log'); + } + + } + + +} + + -} \ No newline at end of file