2012-02-16 47 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(); 
} 

希望这是有帮助的

相关问题