Reputation: 3
I have a problem with my system when I opened localhost, it displays this error :
An uncaught Exception was encountered
Type: RuntimeException
Message: Unable to locate the model you have specified: Project_model
Filename: C:\xampp\htdocs\txu\system\core\Loader.php
Line Number: 344
Backtrace:
File: C:\xampp\htdocs\txu\application\controllers\home.php Line: 9 Function: model
File: C:\xampp\htdocs\txu\index.php Line: 315 Function: require_once
this model: Project_model.php
class Project_model extends CI_Model{
function __construct()
{
parent::__construct();
}
this is controller: Project.php
class Project extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->model('project_model');
}
this is my home controller: home.php
class Home extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->model('Project_model');
}
before this it working, i dont know why it does not working right now. And the console show an error in localhost:
GET http://localhost/txu/ 500 (Internal Server Error)
Can anyone give me suggestion or idea? thank you.
Upvotes: 0
Views: 9396
Reputation: 181
In Codeigniter around version 2.1; you instantiate model like below > Note that it starts on upper case
$this->load->model('Project_model');
While on codeigniter version 3+; you always instantiate model starting lower case, or should i say all lower case
$this->load->model('project_model');
Therefore I would like you to check on your codeigniter version if what fits you.
Same on Usage if you instantiate your model like "Project_model", then use it as:
$this->Project_model->action();
it has case sensitivity;
Upvotes: 0
Reputation: 462
For project module;
Create the controller names as Project.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Project extends CI_Controller {
public function index()
{
$this->load->model('project_model');
echo $this->project_model->my_model_func();
echo "<br> This is the Project Controller";
}
}
Create the model named as Project_Model.php
class Project_model extends CI_Model {
public function my_model_func()
{
echo "Project_model model loaded with my_model_func";;
}
}
And see the output on http://your-base-url/index.php/project You should see the output as
Project_model model loaded with my_model_func
This is the Project Controller
I hope this will work for you.
Upvotes: 1