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
I use codeigniter 3+. I had the same problem and in my case I changed model file name starting from uppser case.
Logon_model.php
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 Test_Model extends CI_Model
Test_Model.php
$this->load->model('Test_Model');
$this->Test_Model
To avoid using hard coding strings you can load model like this:
$this->load->model(Test_Model::class);
Here is what a model should look like: Make sure yours is like this.
<?php
class Logon_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function myFunc()
{
// do something
}
}
note the upper-case class name.
To load it use:
$this->load->model('logon_model');
note all lower case.
I resolve this with this way:
$autoload['model'] = array('Page_model'=>'page');
Works fine.. I hope help.
you must change your model name first letter capital. in localhost small letter work properly but online this not work. for exa:
common_model.php
replaced it to
Common_model.php
Just adding my problem i had:
$this->load->model("planning/plan_model.php");
and the .php
shouldnt be there, so it should have been:
$this->load->model("planning/plan_model");
hope this helps someone