2013-03-13 65 views
0

我在我的代碼中收到一個錯誤,不知道爲什麼。以下是錯誤:控制器刪除功能錯誤

Fatal error: Call to undefined method Display::index() in 

下面是導致該錯誤的控制器部分:

function delete(){ 
    $this->load->model('display_model'); 
    $this->display_model->delete_row(); 
    $this->index(); 

} 

和模型的一部分,如果萬一需要:

function delete_row() 
      { 
      $this->db->where('QID', $this->uri->segment(3)); 
      $this->db->delete('tblquestions'); 
      } 

回答

2

相反,你可以這樣做如下:

function delete(){ 
    $this->load->model('display_model'); 
    $this->display_model->delete_row(); 
    redirect('/controllerName/', 'refresh'); 
} 

The be重定向nefit是你可以設置一些消息給用戶,你已經完成或沒有通過傳遞一些id做出行動。

function delete(){ 
    $this->load->model('display_model'); 
    $this->display_model->delete_row(); 
    redirect('/controllerName/index/1', 'refresh'); 
} 
+0

它修復了錯誤,但不會刪除表 – user2143150 2013-03-13 13:27:10

+0

中的選定行,只是使用事件探查器檢查您的查詢。 – 2013-03-13 13:30:21

+0

你能解釋一下嗎?我是新來的這個daunt真的明白你說的是什麼? – user2143150 2013-03-13 13:36:48