CodeIgniter PHP Model Access “Unable to locate the model you have specified”

前端 未结 16 1304
耶瑟儿~
耶瑟儿~ 2020-11-30 02:10

I have been trying to load some models for this website I am building. However, for an unknown reason, it will bring the following error :

An Error Was Encou         


        
16条回答
  •  难免孤独
    2020-11-30 02:10

    You can give whatever name you want.

    Styles guides are recommendations and not musts.

    But you have to care to use everywhere the same name.

    For example for Test_Model you have to:

    Class Name

            class Test_Model extends CI_Model
    

    File Name

            Test_Model.php
    

    Load Model

            $this->load->model('Test_Model');
    

    Use Model

            $this->Test_Model
    

    To avoid using hard coding strings you can load model like this:

            $this->load->model(Test_Model::class);
    

提交回复
热议问题