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.
38 lines
1023 B
38 lines
1023 B
<?php
|
|
|
|
namespace API\script\Gateway;
|
|
|
|
use API\script\Config\Connection;
|
|
use PDO;
|
|
|
|
class GatewayPossibleResponse
|
|
{
|
|
private Connection $connection;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->connection = connect();
|
|
}
|
|
|
|
public function getPossibleResponseByQuestion(string $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();
|
|
}
|
|
}
|