繁体   English   中英

无法找到您指定的模型:modelName

[英]Unable to locate the model you have specified: 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

CodeIgniter无法找到模型的文件。 如果您将模型命名为Menu ,请确保文件名为menu.php而不是menu_model.php

确保型号名称为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();
}

希望这很有帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM