CodeIgniter Forums
Model error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Model error (/showthread.php?tid=69972)



Model error - neuron - 02-05-2018

Hi, recently I start seeing Model error in logs. It happens rarely but I wanted to know reason.
Error saying:
ERROR - 2018-02-05 13:57:26 --> Severity: error –> Exception: /public_html/application/models/Car_model.php exists, but doesn't declare class Car_model /public_html/system/core/Loader.php 336

My Car_model.php:
PHP Code:
<?php if (!defined('BASEPATH'))  exit('No direct script access allowed');


class 
Car_model extends CI_Model 
starts this way.

What might cousing this error?


RE: Model error - InsiteFX - 02-06-2018

Are you just loading the Model in a controller or are you auto loading it?

If it's in a controller try loading it in the controllers __constructor.


RE: Model error - dave friend - 02-06-2018

You're saying this happens intermittently? In other words, sometimes the class loads, but sometimes it won't?


RE: Model error - neuron - 02-06-2018

I am loading it in MY_Controller.

yes Dave it happens intermittently 

PHP Code:
class MY_Controller extends CI_Controller {

    public function 
__construct() {

        
parent::__construct();
        
$this->load->model('utility_model');
        
$this->load->model('blogs_model');
        
$this->load->model('car_model');
}




RE: Model error - InsiteFX - 02-06-2018

If your going to load it in the MY_Controller you might as well autoload them.

I would load them in the Controllers that use them.