2016-10-04 39 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