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.

43 lines
1.2 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($e->getMessage(), $e->getCode(), $e);
}
}
public function getPossibleResponseByQuestion(int $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, PDO::PARAM_INT)
));
return $this->connection->getResults();
}
public function insertPossibleResponse(string $contentPossibleResponse): int
{
$query = "INSERT INTO PossibleResponse(content) VALUES(:content)";
$this->connection->executeQuery($query, array(
':content' => array($contentPossibleResponse, PDO::PARAM_STR)
));
return $this->connection->lastInsertId();
}
}