connection = connect(); } public function getDetailsListResponsesOfCandidate(int $idListResponse) { $gatewayResponse = new GatewayResponse(); $gatewayKeyword = new GatewayKeyword(); $tabKeywords = []; $query = "SELECT * FROM ListResponsesOfCandidate WHERE id = :id"; $this->connection->executeQuery($query, array( ':id' => array($idListResponse, PDO::PARAM_INT) )); $questionList = $this->connection->getResults()[0]; $responses = $gatewayResponse->getResponsesByIdListCandidate($questionList['id']); foreach ($responses as $row) { $tabKeywords[] = $gatewayKeyword->getKeywordsContentByCategorieze($row['id']); } return array($questionList, $responses, $tabKeywords); } public function getAllListResponsesOfCandidate(): array { $query = "SELECT * FROM ListResponsesOfCandidate"; $this->connection->executeQuery($query); return $this->connection->getResults(); } public function deleteListResponseOfCandidate($id): void { $gatewayResponse = new GatewayResponse(); foreach ( $gatewayResponse->getResponsesIdByIdListCandidate($id) as $response){ $gatewayResponse->deleteResponseById($response); } $query = "DELETE FROM ListResponsesOfCandidate WHERE id = :id"; $this->connection->executeQuery($query, array( 'id' => array($id, PDO::PARAM_STR) )); } public function insertListResponsesOfCandidate($id, $answer, $category, $titleForm) { $gatewayResponse = new GatewayResponse(); $gatewayQuestion = new GatewayQuestion(); $query = "INSERT INTO ListResponsesOfCandidate(date, titleForm) VALUES(:date, :titleForm)"; $this->connection->executeQuery($query, array( ':date' => array(date('d-m-y h:i:s'), PDO::PARAM_STR), 'titleForm' => array($titleForm, PDO::PARAM_STR) )); $idListQuestion = $this->connection->lastInsertId(); for($i = 0; $i < count($answer); $i++) { $idResponse = $gatewayResponse->insertResponse($gatewayQuestion->getQuestionContentById($id[$i]), $answer[$i], $category[$i]); $query = "INSERT INTO Submit (responsesCandidate, response) VALUES(:responsesCandidate, :response)"; $this->connection->executeQuery($query, array( ':responsesCandidate' => array($idListQuestion, PDO::PARAM_STR), 'response' => array($idResponse, PDO::PARAM_STR) )); } } }