diff --git a/Source/API/script/Gateway/GatewayForm.php b/Source/API/script/Gateway/GatewayForm.php index 738dd7b..1154665 100644 --- a/Source/API/script/Gateway/GatewayForm.php +++ b/Source/API/script/Gateway/GatewayForm.php @@ -37,16 +37,23 @@ class GatewayForm return $this->connection->getResults(); } - public function assignKeywordToQuestion(string $keyword, string $response, int $idQuestion) + public function deleteForm(Form $form): void + { + $query = "DELETE FROM Form WHERE id = :id"; + $this->connection->executeQuery($query, array( + ':id' => array($form->getId(), PDO::PARAM_INT) + )); + } + + public function assignKeywordToQuestion(string $keyword, string $response, int $idQuestion): void { echo $keyword; $query = "SELECT pr.id FROM Propose p, PossibleResponse pr WHERE p.question = :id AND p.possibleResponse = pr.id AND pr.content = :response"; $this->connection->executeQuery($query, array( - ':id' => array($idQuestion, PDO::PARAM_STR), + ':id' => array($idQuestion, PDO::PARAM_INT), ':response' => array($response, PDO::PARAM_STR) )); - $idPossibleResponse = $this->connection->getResults()[0][0]; $query = "INSERT INTO Reference(possibleResponse, keyword) VALUES(:possibleResponse, :keyword)"; @@ -56,11 +63,11 @@ class GatewayForm )); } - public function deleteKeywordFromQuestion(string $keyword, string $response, Question $question) + public function deleteKeywordFromQuestion(string $keyword, string $response, Question $question): void { $query = "SELECT pr.id FROM Propose p, PossibleResponse r WHERE p.question = :id AND p.possibleResponse = pr.id AND pr.content = :response"; $this->connection->executeQuery($query, array( - ':id' => array($question->getId(), PDO::PARAM_STR), + ':id' => array($question->getId(), PDO::PARAM_INT), ':response' => array($response, PDO::PARAM_STR) )); @@ -69,7 +76,34 @@ class GatewayForm $query = "DELETE FROM Reference WHERE response = :idResponse AND keyword = :idKeword"; $this->connection->executeQuery($query, array( ':idResponse' => array($idPossibleResponse, PDO::PARAM_INT), - ':idKeword' => array($keyword->getId(), PDO::PARAM_INT) + ':idKeword' => array($keyword, PDO::PARAM_INT) + )); + } + + public function updateTitleToForm(string $title, Form $form): void + { + $query = "UPDATE Form SET title = :title WHERE id = :id"; + $this->connection->executeQuery($query, array( + ':title' => array($title, PDO::PARAM_STR), + ':id' => array($form->getId(), PDO::PARAM_INT) + )); + } + + public function updateDescriptionToForm(string $description, Form $form): void + { + $query = "UPDATE Form SET title = :title WHERE description = :description"; + $this->connection->executeQuery($query, array( + ':description' => array($description, PDO::PARAM_STR), + ':id' => array($form->getId(), PDO::PARAM_INT) + )); + } + + public function deleteDescriptionToForm(Form $form): void + { + $query = "UPDATE Form SET title = :title WHERE description = :description"; + $this->connection->executeQuery($query, array( + ':description' => array('', PDO::PARAM_STR), + ':id' => array($form->getId(), PDO::PARAM_INT) )); } } \ No newline at end of file diff --git a/Source/API/script/Gateway/GatewayKeyword.php b/Source/API/script/Gateway/GatewayKeyword.php index 5068a8d..75e4a44 100644 --- a/Source/API/script/Gateway/GatewayKeyword.php +++ b/Source/API/script/Gateway/GatewayKeyword.php @@ -14,7 +14,7 @@ class GatewayKeyword $this->connection = connect(); } - public function insertKeyword(Keyword $keyword) + public function insertKeyword(Keyword $keyword): void { $query = "INSERT INTO Keyword(id, word) VALUES(:id, :word)"; $this->connection->executeQuery($query, array( @@ -23,7 +23,7 @@ class GatewayKeyword )); } - public function deleteKeyword(Keyword $keyword) + public function deleteKeyword(Keyword $keyword): void { $query = "DELETE FROM Keyword WHERE id = :id"; $this->connection->executeQuery($query, array( diff --git a/Source/API/script/Gateway/GatewayQuestion.php b/Source/API/script/Gateway/GatewayQuestion.php index bfc9aac..aeffcdb 100644 --- a/Source/API/script/Gateway/GatewayQuestion.php +++ b/Source/API/script/Gateway/GatewayQuestion.php @@ -95,7 +95,7 @@ class GatewayQuestion )); } - public function getAllQuestions(string $idForm): array //revoie un array contenant trois qui pour chaque indice commun de ces 3 array une question, sa liste de reponse possible et sa liste de keyword associer au réponse. les deux autres sont null si c'est une textBox + public function getAllQuestions(string $idForm): array //renvoie un array contenant trois qui pour chaque indice commun de ces 3 array une question, sa liste de reponse possible et sa liste de keyword associer au réponse. les deux autres sont null si c'est une textBox { $query = "SELECT * FROM Question WHERE form = :form"; $this->connection->executeQuery($query, array(