response( array( 'error' => 'Data not found' ), 404); } /** * Method GET * Get single record (by id) * http://DOMAIN/trips/1 * @return string */ public function viewAction() { //id must be the first parameter after /trips/x $id = array_shift($this->requestUri); if($id && (int)$id>0){ $db = new Db(); $tripOptions = Trips::getOptionsById($db->getConnect(), (int)$id); if(is_array($tripOptions) && count($tripOptions)>0){ return $this->response( array( 'id' => $id, 'count' => count($tripOptions), 'options' => $tripOptions ), 200); } } return $this->response( array( 'error'=> 'Data not found' ), 404); } public function createAction() { return $this->response( array( "error" => "Saving error" ), 500); } public function updateAction() { return $this->response( array( "error" => "Update error" ), 400); } public function deleteAction() { return $this->response( array( "error" => "Delete error" ), 500); } }