我有一个在本地计算机上运行的codeigniter api。所有功能都运行良好。 但是当我将项目上传到服务器时,它开始引起问题。获取请求没问题。但问题在于put,post和delete请求。 该项目工作正常。问题出在api中。
这是我的休息控制器
function customer_put(){
$this->load->model('registration_model');
$ids = $this->registration_model->last_id_customer();
foreach ($ids as $id){
}
$last_id = ($id->id)+1;
$cus_id = 'cus-'.$last_id;
$cus_name = $this->put('name');
$cus_father_name = $this->put('father_name');
$cus_address = $this->put('address');
$cus_password = $this->put('password');
$nid = $this->put('nid');
$purpose = $this->put('purpose');
$avg_jar = $this->put('avg_jar');
$order_type = $this->put('order_type_id');
$staff_id = $this->put('staff_id');
$create = $this->registration_model->customer_reg_api($cus_id,$cus_name,$cus_password,$cus_father_name,$cus_address,$nid,$purpose,$avg_jar,$order_type,$staff_id);
if($create){
$message = array(
'Message'=>'Customer created',
'customer_id'=>$cus_id
);
$this->response($message, REST_Controller::HTTP_CREATED);
} else {
$this->response('Customer creation failed',REST_Controller::HTTP_FORBIDDEN);
}
}
错误在邮差中显示如下
<h1>A Database Error Occurred</h1>
<p>Error Number: 1048</p>
<p>Column 'order_type_id' cannot be null</p>
<p>INSERT INTO `customer` (`cus_id`, `name`, `password`, `father_name`, `address`, `nid`, `purpose`, `avg_jar`, `order_type_id`, `staff_id`) VALUES ('cus-10', NULL, 'd41d8cd98f00b204e9800998ecf8427e', NULL, NULL, NULL, NULL, NULL, NULL, NULL)</p>
<p>Filename: models/Registration_model.php</p>
<p>Line Number: 114</p>
我是邮递员在体内发送的数据。不知道问题出在哪里。