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.

53 lines
1.5 KiB

<?php
class GatewayAnswer
{
private $con;
public function __construct($con)
{
$this->con = $con;
}
public function addAnswer($answer)
{
$query = "insert into Answer(id,content) values (:id,:content);";
$this->con->executeQuery(
$query,
array(
':id' => array($answer->getId(), PDO::PARAM_INT),
':content' => array($answer->getContent(), PDO::PARAM_STR)
)
);
}
public function getAnswerByIDQuestions($idQuestions)
{
$query = "SELECT * FROM answers, questions WHERE questions.id = :idQuestions;";
$this->con->executeQuery($query, array(':idQuestions' => array($idQuestions, PDO::PARAM_INT)));
$results = $this->con->getResults();
if ($results == NULL) {
return false;
}
return new Answer($results[0]['id'], $results[0]['content']);
}
public function updateAnswer($answer)
{
$query = "UPDATE Answer SET content = :content WHERE id = :id;";
$this->con->executeQuery(
$query,
array(
':id' => array($answer->getId(), PDO::PARAM_INT),
':content' => array($answer->getContent(), PDO::PARAM_STR)
)
);
}
public function deleteAnswer($id)
{
$query = "DELETE FROM Answer WHERE id = :id;";
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
}
}