2012-02-16 51 views
3

我試圖加載這個模型MODELNAME:無法找到您所指定的型號:

class Menu { 

    function show_menu() 
    { 
     $obj =& get_instance(); 
     $obj->load->helper('url'); 
     $menu = anchor("start/hello/fred","Say hello to Fred |"); 
     $menu .= anchor("start/hello/bert","Say hello to Bert |"); 
     $menu .= anchor("start/another_function","Do something else |"); 
     return $menu; 
    } 

} 

這是我的控制器:

function hello($name) 
{ 
    $this->load->model('Menu'); 
    $mymenu = $this->Menu->show_menu(); 
} 

爲什麼我得到這個錯誤?

Unable to locate the model you have specified: menu

回答

5

笨找不到型號的文件。如果您命名模型Menu,請確保文件名是menu.php而不是其他類似menu_model.php

+0

謝謝,它幫助 – BlackFire27 2012-02-16 17:24:28

0

確保型號名稱是菜單和類的名稱也是菜單

class Menu extends CI_Model{ 

    function show_menu() 
    { 
     $obj =& get_instance(); 
     $obj->load->helper('url'); 
     $menu = anchor("start/hello/fred","Say hello to Fred |"); 
     $menu .= anchor("start/hello/bert","Say hello to Bert |"); 
     $menu .= anchor("start/another_function","Do something else |"); 
     return $menu; 
    } 

} 

但加載類是「菜單」而不是「菜單」

function hello($name) 
{ 
    $this->load->model('menu'); 
    $mymenu = $this->menu->show_menu(); 
} 

希望這是有幫助的

相關問題