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.
47 lines
1.4 KiB
47 lines
1.4 KiB
<?php
|
|
|
|
class GatewayQuestion
|
|
{
|
|
private $con;
|
|
|
|
public function __construct($con)
|
|
{
|
|
$this->con = $con;
|
|
}
|
|
|
|
public function addQuestion($question)
|
|
{
|
|
$query = "insert into Question(id,content,difficulty,nbFails) values (:id,:content,:difficulty,:nbFails);";
|
|
$this->con->executeQuery(
|
|
$query,
|
|
array(
|
|
':id' => array($question->getId(), PDO::PARAM_INT),
|
|
':content' => array($question->getContent(), PDO::PARAM_STR),
|
|
':difficulty' => array($question->getDifficulty(), PDO::PARAM_INT),
|
|
':nbFails' => array($question->getNbFails(), PDO::PARAM_INT)
|
|
)
|
|
);
|
|
}
|
|
|
|
public function getQuestionByID($id)
|
|
{
|
|
$query = "SELECT * FROM Question WHERE id = :id;";
|
|
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
|
|
$results = $this->con->getResults();
|
|
if ($results == NULL) {
|
|
return false;
|
|
}
|
|
return new Question($results[0]['id'], $results[0]['content'], $results[0]['difficulty'], $results[0]['nbFails']);
|
|
}
|
|
|
|
public function getQuestions()
|
|
{
|
|
$query = "SELECT * FROM Question;";
|
|
$this->con->executeQuery($query);
|
|
$results = $this->con->getResults();
|
|
if ($results == NULL) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|