con = $con; } public function addChapter($chapter) { $query = "insert into Chapters(id,name) values (:id,:name);"; $this->con->executeQuery( $query, array( ':id' => array($chapter->getId(), PDO::PARAM_INT), ':name' => array($chapter->getName(), PDO::PARAM_STR) ) ); } public function getChapters() { $query = "SELECT * FROM Chapters;"; $this->con->executeQuery($query); $results = $this->con->getResults(); if ($results == NULL) { return false; } $chapters = array(); foreach ($results as $row) { $chapters[] = new Chapter($row['id'], $row['name']); } return $chapters; } public function updateChapter($chapter) { $query = "UPDATE Chapters SET name = :name WHERE id = :id;"; $this->con->executeQuery( $query, array( ':id' => array($chapter->getId(), PDO::PARAM_INT), ':name' => array($chapter->getName(), PDO::PARAM_STR) ) ); } public function deleteChapter($id) { $query = "DELETE FROM Chapters WHERE id = :id;"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); } }