Example #1
0
    }
    private function deleteClient()
    {
        if ($this->get_request_method() != "DELETE") {
            $this->response('', 406);
        }
        $id = (int) $this->_request['id'];
        if ($id > 0) {
            $query = "DELETE FROM tblclient WHERE clientID = {$id}";
            $r = $this->mysqli->query($query) or die($this->mysqli->error . __LINE__);
            $success = array('status' => "Success", "msg" => "Successfully deleted one record.");
            $this->response($this->json($success), 200);
        } else {
            $this->response('', 204);
        }
        // If no records "No Content" status
    }
    /*
     *	Encode array into JSON
     */
    private function json($data)
    {
        if (is_array($data)) {
            return json_encode($data);
        }
    }
}
// Initiiate Library
$api = new ClientAPI();
$api->processApi();