我得到一个错误在我的代码,不知道为什么。下面是错误:
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');
}
你可以这样做:
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');
}