Building Your PHP Rest Service (step 2)
In the article for step 1, we set up the directory structure and covered the config directory. Using standard top-down approach, we are moving on to the objects directory today. In this REST service, we have a list of wineries, their online listings and a trivia page. This means we need three object files inside of the directory – online.php, trivia.php and wineries.php. The code shown below is for online.php. <?php class Online{ // database connection and table name private $conn; private $table_name = "Online"; // object properties public $id; public $description; public $url; public $recid; // constructor with $db as database connection public function __construct($db){ $this->conn = $db; } function reviewsById($id){ // select reviews for winery $query = "SELECT id,description,url,recid FROM " . $this->table_name . " where id = ?…







