我正在使用 codeigniter REST API。在我的 API 调用中,我试图从中获取价值,$this->input->get('id')
但没有从 get 中获得任何价值。
public function data_get($id_param = NULL){
$id = $this->input->get('id');
if($id===NULL){
$id = $id_param;
}
if ($id === NULL)
{
$data = $this->Make_model->read($id);
if ($data)
{
$this->response($data, REST_Controller::HTTP_OK);
}
else
{
$this->response([
'status' => FALSE,
'error' => 'No record found'
], REST_Controller::HTTP_NOT_FOUND);
}
}
$data = $this->Make_model->read($id);
if ($data)
{
$this->set_response($data, REST_Controller::HTTP_OK);
}
else
{
$this->set_response([
'status' => FALSE,
'error' => 'Record could not be found'
], REST_Controller::HTTP_NOT_FOUND);
}
}
在上面的代码中 $id 不返回任何值。