con = $con; } public function addAnswer($answer) { $query = "insert into Answers(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 Answers 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 Answers WHERE id = :id;"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); } }