/** * Creates an movie object based on a DB row. * * @param array $row The DB row containing movie data. * @return \MicroCMS\Domain\movie */ protected function buildDomainObject($row) { $movie = new Movie(); $movie->setId($row['mov_id']); $movie->setTitle($row['mov_title']); $movie->setDescriptionCourte($row['mov_description_short']); return $movie; }
/** * Creates an Article object based on a DB row. * * @param array $row The DB row containing Article data. * @return \MicroCMS\Domain\Article */ protected function buildDomainObject($row) { $movie = new Movie(); $movie->setId($row['mov_id']); $movie->setTitle($row['mov_title']); $movie->setDescriptionCourt($row['mov_description_short']); $movie->setDescriptionLong($row['mov_description_long']); $movie->setDirector($row['mov_director']); $movie->setYear($row['mov_year']); return $movie; }
/** * Creates an Movie object based on a DB row. * * @param array $row The DB row containing Movie data. * @return \MyMovies\Domain\Movie */ private function buildMovie(array $row) { $movie = new Movie(); $movie->setId($row['mov_id']); $movie->setTitle($row['mov_title']); $movie->setDescriptionShort($row['mov_description_short']); $movie->setDescriptionLong($row['mov_description_long']); $movie->setDirector($row['mov_director']); $movie->setYear($row['mov_year']); $movie->setImage($row['mov_image']); $movie->setCatId($row['cat_id']); return $movie; }
/** * Saves a movie into the database. * * @param \MyMovies\Domain\Article $article The article to save */ public function save(Movie $movie) { $movieData = array('mov_title' => $movie->getTitle(), 'mov_description_long' => $movie->getDescriptionLong(), 'mov_description_short' => $movie->getDescriptionShort(), 'mov_director' => $movie->getDirector(), 'mov_year' => $movie->getYear(), 'mov_image' => $movie->getImage()); if ($movie->getId()) { // The article has already been saved : update it $this->getDb()->update('movie', $movieData, array('mov_id' => $movie->getId())); } else { // The article has never been saved : insert it $this->getDb()->insert('movie', $movieData); // Get the id of the newly created user and set it on the entity. $id = $this->getDb()->lastInsertId(); $movie->setId($id); } }
protected function buildDomainObject($row) { $movie = new Movie(); $movie->setId($row['mov_id']); $movie->setTitle($row['mov_title']); $movie->setDescriptionShort($row['mov_description_short']); $movie->setDescriptionLong($row['mov_description_long']); $moviet->setDirector($row['mov_director']); $movie->setYear($row['mov_year']); $movie->setImage($row['mov_image']); if (array_key_exists('cat_id', $row)) { $categoryId = $row['cat_id']; $category = $this->categoryDAO->find($categoryId); $movie->setCategory($category); } return $movie; }