2016-01-07 134 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))); 
     } 
    } 
}