/** * Create a new record in the database * * @param Author $author * @return boolean */ protected function insert(Author $author) { $id = Uuid::v4(); $sql = 'INSERT INTO author (id, name, biography) VALUES (:id, :name, :biography)'; $params = ['id' => $id, 'name' => $author->getName(), 'biography' => $author->getBiography()]; $statement = $this->dbAdapter->prepare($sql); if ($statement->execute($params)) { $author->setId($id); return true; } return false; }
/** * Create a new record in the database * * @param Book $book * @return boolean */ protected function insert(Book $book) { $id = Uuid::v4(); $sql = 'INSERT INTO book (id, author_id, title, isbn, date_published) VALUES (:id, :author_id, :title, :isbn, :date_published)'; $params = ['id' => $id, 'author_id' => $book->getAuthorId(), 'title' => $book->getTitle(), 'isbn' => $book->getIsbn(), 'date_published' => $book->getDatePublished()]; $statement = $this->dbAdapter->prepare($sql); if ($statement->execute($params)) { $book->setId($id); return true; } return false; }