Exemple #1
0
 /**
  * Creates a Book object based on a DB row.
  * 
  * @param array $row The DB row containing the Book data.
  * @return \MyBooks\Domain\Book
  */
 protected function buildDomainObject($row)
 {
     $book = new Book();
     $book->setId($row['book_id']);
     $book->setTitle($row['book_title']);
     $book->setIsbn($row['book_isbn']);
     $book->setSummary($row['book_summary']);
     $book->setAuthor($this->authorDAO->find($row['auth_id']));
     return $book;
 }
Exemple #2
0
 /**
  * Creates a Book object based on a DB row.
  *
  * @param array $row The DB row containing Book data.
  * @return \MyBooks\Domain\Book
  */
 protected function buildDomainObject($row)
 {
     $book = new Book();
     $book->setId($row['book_id']);
     $book->setTitle($row['book_title']);
     $book->setIsbn($row['book_isbn']);
     $book->setSummary($row['book_summary']);
     if (array_key_exists('auth_id', $row)) {
         // Find and set the associated article
         $authorId = $row['auth_id'];
         $author = $this->authorDAO->find($authorId);
         $book->setAuthor($author);
     }
     return $book;
 }