php – 通过在CodeIgniter中发送PUT请求来插入数据(Phil Sturgeo
发布时间:2020-12-13 21:50:27 所属栏目:PHP教程 来源:网络整理
导读:我通过API中的REST CLIENT发送的PUT和POST请求之间存在差异.它在CodeIgniter中与Phil Sturgeon的REST服务器一起实现. function station_put(){ $data = array( 'name' = $this-input-post('name'),'number' = $this-input-post('number'),'longitude' = $thi
我通过API中的REST CLIENT发送的PUT和POST请求之间存在差异.它在CodeIgniter中与Phil Sturgeon的REST服务器一起实现.
function station_put(){ $data = array( 'name' => $this->input->post('name'),'number' => $this->input->post('number'),'longitude' => $this->input->post('longitude'),'lat' => $this->input->post('latitude'),'typecode' => $this->input->post('typecode'),'description' => $this->input->post('description'),'height' => $this->input->post('height'),'mult' => $this->input->post('mult'),'exp' => $this->input->post('exp'),'elevation' => $this->input->post('elevation') ); $id_returned = $this->station_model->add_station($data); $this->response(array('id'=>$id_returned,'message'=>"Successfully created."),201); } 此请求成功地将数据插入到服务器BUT中 – 除了id之外,它将其余值呈现为NULL. 但是,如果将函数名称更改为station_post,则会正确插入数据. 有人请指出为什么PUT请求不起作用?我使用的是最新版本的谷歌浏览器. 顺便说一下,这个API将集成到BackBone处理的应用程序中.我真的需要使用PUT吗?或者在使用post时,是否还有另一种使用骨干模型保存功能的解决方法? 解决方法
终于回答了.而不是$this-> input-> post或$this-> input-> put,它必须是$this-> put或$this-> post,因为数据不是来自表单.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |