2016-10-04 102 views
0

我是codeigniter的新手,嘗試使用來更新記錄REST控制器但無法在此成功。無法在代碼更新中使用post方法

控制器代碼:

function user_post() 
    { 
     $data = array(
      'title' => $this->post('title'), 
      'text' => $this->post('text') 
     ); 

     $result = $this->hello_model->update_entry($this->post('id'), $data); 

     if($result === FALSE) 
     { 
      $this->response(array('status' => 'failed')); 
     } 

     else 
     { 
      $this->response(array('status' => 'success')); 
     } 

    } 

型號代碼:

public function update_entry($id,$data) 
     { 
      $this->db->where('id', $id); 
     $this->db->update('news', $data); 

     } 
+0

什麼錯誤? – Elby

+0

不能得到任何錯誤,它會返回成功,但不會更新表中的數據。 –

+0

檢查print_r($結果)的結果 – Elby

回答

0

試試這個:

$result = $this->hello_model->update_entry($this->input->post('id') 
+1

請[編輯]你的答案解釋我們爲什麼要試試這個。此外,您可以通過使用四個空格縮進代碼來使代碼看起來像代碼一樣。 – dorukayhan