Welcome Guest, Not a member yet? Register   Sign In
Loading Model for Module
#1

[eluser]Tommy Ready[/eluser]
I am using codeigniter in a module based system and inside of my module directory I have the following directories:

my_module
>> controllers
>> models
>> views

Basically Im trying to load a model that is inside this structure from my modules controller

Code:
$this->load->model('my_model');

Here is my controller

Code:
class Mymodule extends CI_Controller
{
        public function index()
        {
          
            $this->load->model('my_model');                
            
        }
}

my model

Code:
Class My_Model Extends CI_Model {
    
    
            function __construct() {
                // Call the Model constructor
                parent::__construct();
            }
}

Not sure whats wrong but I get the error:
Unable to locate the model you have specified: my_model
#2

[eluser]srpurdy[/eluser]
your problem is your not calling MX_Controller

This
Code:
class Mymodule extends CI_Controller

should be
Code:
class Mymodule extends MX_Controller

Also if you need to load a model outside that module but inside another module you can use.

Code:
$this->load->model('module_folder/my_model');
#3

[eluser]Tommy Ready[/eluser]
I still get the same error even after make the 2 suggested changes. Sad
#4

[eluser]USCTrojans[/eluser]
You could try putting the model in the application/models folder to see if it is working. Make sure you are extending CI_Model with your model and not MX_Model. For some reason that doesn't work properly when I do the MX_Model.

Also try putting the module name in the model call like:
$this->load->model('module/model');






Theme © iAndrew 2016 - Forum software by © MyBB