【发布时间】:2017-01-19 16:13:14
【问题描述】:
我在放入 kohana restfull api 时遇到问题。 看起来我的 $post 不起作用,因为在我使用此功能后,我只能看到“找不到数据!”。任何想法?感谢帮助。 这是我的代码。
$trg_id = $this->request->param('id');
if ($trg_id) {
$post = $this->request->post();
if ($post) {
$objTrackingGroup = ORM::factory('Orm_trackingGroup', $trg_id);
if ($objTrackingGroup->loaded()) {
$objTrackingGroup->values($post)
->save();
$this->rest_output($data, 200);
} else {
$data = array(
'code' => 500,
'error' => 'Unknown error'
);
$this->rest_output($data, 500);
}
} else {
$data = array(
'code' => 404,
'error' => 'Data not found!'
);
$this->rest_output($data, 404);
}
}else {
$data = array(
'code' => 404,
'error' => 'Data not found'
);
$this->rest_output($data, 404);
}
【问题讨论】:
-
更新功能好像看不到帖子。
-
您是使用 PUT 还是 POST 方法提交数据?因为 $this->request->post();仅适用于 POST。
标签: rest kohana kohana-3.3