|
|
|
@ -16,12 +16,8 @@ class GatewayResponse
|
|
|
|
|
|
|
|
|
|
public function getResponsesByIdListCandidate(int $listResponsesOfCandidateId)
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT r.* FROM Response r, Submit s WHERE s.responseCandidate = :id AND r.id = s.response";
|
|
|
|
|
$this->connection->executeQuery($query, array(
|
|
|
|
|
':id' => array($listResponsesOfCandidateId, PDO::PARAM_INT)
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
$result = $this->connection->getResults();
|
|
|
|
|
$result = $this->getResponsesIdByIdListCandidate($listResponsesOfCandidateId);
|
|
|
|
|
$tab = [];
|
|
|
|
|
foreach ($result as $row){
|
|
|
|
|
$tab[] = (new GatewayKeyword())->getKeywordsContentByCategorieze($row['id']);
|
|
|
|
@ -30,6 +26,15 @@ class GatewayResponse
|
|
|
|
|
return array($result, $tab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getResponsesIdByIdListCandidate(int $listResponsesOfCandidateId)
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT r.id FROM Response r, Submit s WHERE s.responseCandidate = :id AND r.id = s.response";
|
|
|
|
|
$this->connection->executeQuery($query, array(
|
|
|
|
|
':id' => array($listResponsesOfCandidateId, PDO::PARAM_INT)
|
|
|
|
|
));
|
|
|
|
|
return $this->connection->getResults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteResponseById(int $responseId): void
|
|
|
|
|
{
|
|
|
|
|
$query = "DELETE FROM Categorize WHERE response = :id";
|
|
|
|
@ -48,7 +53,7 @@ class GatewayResponse
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function insertResponse(string $content, string $question): int
|
|
|
|
|
public function insertResponse(string $content, string $question, array $category): void
|
|
|
|
|
{
|
|
|
|
|
$query = "INSERT INTO Response(content, question) VALUES (:content, :question)";
|
|
|
|
|
$this->connection->executeQuery($query, array(
|
|
|
|
@ -56,6 +61,14 @@ class GatewayResponse
|
|
|
|
|
':question' => array($question, PDO::PARAM_STR)
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
return $this->connection->lastInsertId();
|
|
|
|
|
$idResponse = $this->connection->lastInsertId();
|
|
|
|
|
|
|
|
|
|
foreach ($category as $keyword){
|
|
|
|
|
$query = "INSERT INTO Categorize (response, keyword) VALUES(:response, :keyword)";
|
|
|
|
|
$this->connection->executeQuery($query, array(
|
|
|
|
|
':response' => array($idResponse, PDO::PARAM_STR),
|
|
|
|
|
'keyword' => array($keyword, PDO::PARAM_STR)
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|