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');
          }
4

1 回答 1

2

相反,您可以执行以下操作:

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

重定向的好处是您可以通过传递一些 id 向用户设置一些您已完成或未执行操作的消息。

function delete(){
     $this->load->model('display_model');
     $this->display_model->delete_row();
     redirect('/controllerName/index/1', 'refresh');
 }
于 2013-03-13T13:25:21.417 回答