/** * Method to fetch favorite record * * @param $favouriteBO */ public function getallfavourite($favouriteBO) { try { $connection = new ConnectionManager(); $link = $connection->getConnection(); // select query for favourite table $email_id = $favouriteBO->getEmailId(); $query = "SELECT tutorial_id FROM favourite WHERE email_id='{$email_id}' ORDER BY id ASC"; $result = mysql_query($query, $link) or die(mysql_error()); $favouritesArray = array(); while ($success = mysql_fetch_object($result)) { $favourites = new FavouriteBO(); $favourites->setTutorialId($success->tutorial_id); $favourites->getTutorialId(); //storing the objects in an array $favouritesArray[] = $favourites; } return $favouritesArray; // } catch (Exception $e) { throw new Exception("MESSAGE:" . $e->getMessage()); } }
public function deleteFavourite($data) { try { $favouriteBL = new FavouriteBL(); $emailId = $data['email_id']; $tutorialId = $data['tutorial_id']; $favouriteBO = new FavouriteBO(); $favouriteBO->setEmailId($emailId); $favouriteBO->setTutorialId($tutorialId); $success = $favouriteBL->delete($favouriteBO); if ($success == true) { $error = array('status_code' => ERRCODE_RESULT_SUCCESS, 'result_object' => 'success', 'status_message' => MSG_RESULT_SUCCESS); echo json_encode($error); exit; } else { $error = array('status_code' => ERRCODE_RESULT_INVALID, 'result_object' => 'failure', 'status_message' => MSG_RESULT_INVALID); echo json_encode($error); exit; } } catch (Exception $e) { throw new Exception("MESSAGE:" . $e->getMessage()); } }