2016-01-07 81 views

回答

0

这不是一个大问题。一旦完成,您可以执行它。

function user_delete() 
{ 
    // delete a user and respond with a status/errors 
} 

这是删除


要使用JSON格式的数据很公平,将参数添加到网址,如下所示

enter image description here

而且我建议你了解Working with RESTful Services in CodeIgniter

0

@Abdulla提供的答案很公平,但强制您使用其他扩展。如果你想,你可以自己制作其他服务器。例如,端点可以是这样的:

DELETE www.example.com/index.php/api/user/1

和控制器可能是这样的:

<?php 
class Api extends CI_Controller { 

    public function user($id) 
    { 
     $user = User::getById($id); 
     if ($this->input->method() == 'delete') { 
      $user->delete(); 
      /* And example json output */ 
      $this->output 
       ->set_content_type('application/json') 
       ->set_output(json_encode(array('user' => $user))); 
     } 
    } 
}