我正在尝试加载此模型:
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
答案 0 :(得分:5)
CodeIgniter无法找到模型的文件。如果您为模型Menu
命名,请确保文件名为menu.php
,而不是menu_model.php
。
答案 1 :(得分:0)
确保型号名称为Menu,类名称也为Menu
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();
}
希望这很有帮助