/** * Find {@link Todo} by identifier. * @return Todo Todo or <i>null</i> if not found */ public function findById($id) { $row = $this->query('SELECT * FROM blog_restaurant WHERE restaurant_id = ' . (int) $id)->fetch(); if (!$row) { return null; } $blogRestaurant = new BlogRestaurant(); BlogRestaurantMapper::map($blogRestaurant, $row); return $blogRestaurant; }
// private $date; // private $content; // private $createdBy; // private $modifiedBy; // private $description; // private $nameOfRestaurant; // private $overallRating; // private $restaurant_id; // private $username; // private $status = self::PENDING; $blogPostData = array('content' => $_POST['content'], 'date' => $_POST['date'] . ' 00:00:00', 'created_by' => 'char', 'modified_by' => 'char', 'description' => $_POST['content'], 'restaurant_id' => '44', 'status' => 'pending', 'modified_date' => $_POST['date'] . ' 00:00:00'); $blogRestaurantData = array('name_of_restaurant' => $_POST['name_of_restaurant'], 'overall_rating' => $_POST['overall_rating']); $blogChipData = array('chip_colour' => $_POST['chip_colour'], 'chip_crunch' => $_POST['chip_crunch'], 'chip_condiments' => $_POST['chip_condiments'], 'chip_consistency' => $_POST['chip_consistency'], 'chip_cash' => $_POST['chip_cash'], 'chip_charisma' => $_POST['chip_charisma']); // map BlogPostMapper::simpleMap($blogPost, $blogPostData); BlogRestaurantMapper::map($blogRestaurant, $blogRestaurantData); BlogChipMapper::map($blogChip, $blogChipData); // validate $errors = BlogPostValidator::validate($blogPost); $errors = BlogRestaurantValidator::validate($blogRestaurant); if (empty($errors)) { // save $blogPostDao = new BlogPostDao(); $blogRestaurantDao = new BlogRestaurantDao(); $blogChipDao = new BlogChipDao(); $blogPost = $blogPostDao->save($blogPost); $blogRestaurant = $blogRestaurantDao->save($blogRestaurant); $blogChip = $blogChipDao->save($blogChip); Flash::addFlash('Thanks for the review Chipper!'); // redirect Utils::redirect('list', array('status' => 'pending'));