You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
<?php
|
|
|
|
namespace Gateway;
|
|
|
|
use Config\Connection;
|
|
use Config\ConnectClass;
|
|
use PDO;
|
|
use PDOException;
|
|
|
|
class GatewayPossibleResponse
|
|
{
|
|
private Connection $connection;
|
|
|
|
public function __construct()
|
|
{
|
|
try{
|
|
$this->connection = (new ConnectClass)->connect();
|
|
}catch(PDOException $e){
|
|
throw new PDOException();
|
|
} }
|
|
|
|
public function getPossibleResponseByQuestion(array $idQuestion): array
|
|
{
|
|
$query = "SELECT pr.* FROM Propose p, PossibleResponse pr
|
|
WHERE p.question = :questionId AND p.possibleResponse = pr.id";
|
|
$this->connection->executeQuery($query, array(
|
|
':questionId' => array($idQuestion[0], PDO::PARAM_INT)
|
|
));
|
|
|
|
return $this->connection->getResults();
|
|
}
|
|
|
|
public function insertPossibleResponse(array $contentPossibleResponse): int
|
|
{
|
|
$query = "INSERT INTO PossibleResponse(content) VALUES(:content)";
|
|
$this->connection->executeQuery($query, array(
|
|
':content' => array($contentPossibleResponse[0], PDO::PARAM_STR)
|
|
));
|
|
|
|
return $this->connection->lastInsertId();
|
|
}
|
|
} |