@ -37,16 +37,23 @@ class GatewayForm
return $this->connection->getResults();
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;
echo $keyword;
$query = "SELECT pr.id FROM Propose p, PossibleResponse pr WHERE p.question = :id AND p.possibleResponse = pr.id AND pr.content = :response";
$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(
$this->connection->executeQuery($query, array(
':id' => array($idQuestion, PDO::PARAM_STR),
':id' => array($idQuestion, PDO::PARAM_INT ),
':response' => array($response, PDO::PARAM_STR)
':response' => array($response, PDO::PARAM_STR)
));
));
$idPossibleResponse = $this->connection->getResults()[0][0];
$idPossibleResponse = $this->connection->getResults()[0][0];
$query = "INSERT INTO Reference(possibleResponse, keyword) VALUES(:possibleResponse, :keyword)";
$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";
$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(
$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)
':response' => array($response, PDO::PARAM_STR)
));
));
@ -69,7 +76,34 @@ class GatewayForm
$query = "DELETE FROM Reference WHERE response = :idResponse AND keyword = :idKeword";
$query = "DELETE FROM Reference WHERE response = :idResponse AND keyword = :idKeword";
$this->connection->executeQuery($query, array(
$this->connection->executeQuery($query, array(
':idResponse' => array($idPossibleResponse, PDO::PARAM_INT),
':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)
));
));
}
}
}
}