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

前端 未结 16 1278
耶瑟儿~
耶瑟儿~ 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条回答
  •  萌比男神i
    2020-11-30 02:30

    When creating models, you need to place the file in application/models/ and name the file in all lowercase - like logon_model.php

    The logon_model.php should contain the following:

    Now, what you can do, to test if your application model is reachable, is to try opening it in the browser - like so:
    http://example.org/application/models/logon_model.php

    If you see the text No direct script access allowed it means you hit the right file (if you are in doubt, try writing something else in the exit() in the first line).

    Secondly, for loading the model in your controllers, you should be able to do like this:

    public function index()
    {
    
        $this->load->model('logon_model');
        ...
    
    }
    

    If everything above checks out as expected I would begin looking at file permissions and/or possibly symlinks if you are using any.

提交回复
热议问题