2016-10-10 52 views
-1

我得到错误default_method没有定义笨_remap错误未定义default_method

这是我的URL访问

  • 管理/说明/ 1

的ID从数据库中生成(此如果没有_remap工作,但在_remap时不工作)

  • 管理/说明/更新

我的公共功能更新()(如果没有_remap & &有 _remap这不行)

这是我的控制器

public function _remap($method) 
    { 
     if ($method === 'update') 
     { 
      $this->$method(); 
     } 
     else 
     { 
      $this->default_method(); 
     } 
    } 
    public function index($id = NULL) 
    { 
     $exits_id = $this->Description_model->get_all_id(); 

     if(count($exits_id) > 0) 
     { 
      foreach($exits_id as $exits_id): 

       $id_arr[]=$exits_id->desc_id; 

      endforeach; 
     } 

     if(!in_array($id, $id_arr)) 
     { 
      show_404(); 
     } 
     $viewdata['content']=$this->General_model->get_page_uri(); 
     $viewdata['ha']='Indroduction/'. $id.'/'; 
     $this->load->view("backend/content_view",$viewdata); 
    } 
    public function update() 
    { 
     echo 'update'; 
    } 

这是我的路线

$method_arr=array(
      'Dashboard', 
      'Googlemap', 
      'Deccription', 
      'Slideshow' 
      ); 
foreach($method_arr as $method_arr){ 
    $route['Admin/'.strtolower($method_arr)] = 'backend/'.$method_arr; 
    $route['Admin/'.$method_arr] = 'backend/'.$method_arr; 

    $route['Admin/'.strtolower($method_arr).'/(:any)'] = 'backend/'.$method_arr.'/$1'; 

    $route['Admin/'.$method_arr.'/(:any)'] = 'backend/'.$method_arr.'/$1'; 
    /*This 1 line above read my function method */ 
} 

$route['Admin/Description/(:any)'] = 'backend/Description/index/$1'; 
/*This 1 line above read my index($id = NULL) */ 

错误:调用未定义的方法描述:: default_method()

回答

0
问题

是解决删除功能_remap()

和改变路由索引($ ID = NULL)对于其他$航线的顶部

$route['Admin/Description/(:num)'] = 'backend/Description/index/$1'; 
/*This 1 line above read my index($id = NULL) */ 

foreach($method_arr as $method_arr){ 
    $route['Admin/'.strtolower($method_arr)] = 'backend/'.$method_arr; 
    $route['Admin/'.$method_arr] = 'backend/'.$method_arr; 

    $route['Admin/'.strtolower($method_arr).'/(:any)'] = 'backend/'.$method_arr.'/$1'; 

    $route['Admin/'.$method_arr.'/(:any)'] = 'backend/'.$method_arr.'/$1'; 
    /*This 1 line above read my function method */ 
} 

,但我有问题怎么$航线覆盖其他航线$

  • 顶部的$ route会覆盖每条向下的$ route吗?
  • 在Down的$ route会覆盖每个Top $路线?