Unable to locate the model you have specified - CodeIgniter Issue

后端 未结 9 443
不知归路
不知归路 2021-01-14 03:55

I\'m getting an unable to locate model error.

$this->load->model(\'1/Gift_model\');

My model file name is gift_model.php

相关标签:
9条回答
  • 2021-01-14 04:19

    The problem is that your file name is all lowercase (gift_model.php) while you are loading Gift_model within CodeIgniter. Either change the file name to Gift_model.php or update your code accordingly.

    0 讨论(0)
  • 2021-01-14 04:19

    `if using codeignitor 3.1.3
    every thing same otherwise showing error class name => My_model

    file name => My_model.php

    load model => $this->load->model('My_model');

    call function => $this->My_model->function();`

    0 讨论(0)
  • 2021-01-14 04:21

    Are you calling the parent's constructor for the model?

    class Gift_model extends CI_Model {
        function __construct()
        {
            parent::__construct();
        }
    
    0 讨论(0)
  • 2021-01-14 04:22
    1. Make the model class name Uppercase My_model
    2. Make the model php file name Lowercase my_model
    3. Load the model using Lowercase (file name) $this->load->model('my_model');
    0 讨论(0)
  • 2021-01-14 04:25

    Starting with CodeIgniter 3.0, all class filenames (libraries, drivers, controllers and models) must be named in a Ucfirst-like manner or in other words - they must start with a capital letter.

    (Source: CI docs)

    0 讨论(0)
  • 2021-01-14 04:26
    -> Model Class name must be Uppercase
    -> Model PHP file name must be Lowercase
    -> Load Model using Lowercase(filename): $this->load->model('gift_model', TRUE);
    
    0 讨论(0)
提交回复
热议问题