Could not load model over Autoload |
Hey,
i have a little strange Problem. When i try to load a model over the Autoload.php and try to use it, i'll become an Error that the model could not found (Undefined property: Home::$users_to_groups), but when i load it over $this->load->model() it works. But why? Here is the Code that i Use: PHP Code: <?php Has anywhone an Idea what i do wrong? When i insert the commented Line, than the script is full functionally (the groups_to_rights modal can be found).
Your class needs to extend CI_Model.
http://www.codeigniter.com/user_guide/ge...odels.html
How are you listing the model in your config/autoload.php file? To get the same result as this:
PHP Code: $this->_ci->load->model('rights/Users_to_groups_model', 'users_to_groups'); You need to use something like this: PHP Code: $autoload['model'] = ['rights/Users_to_groups_model' => 'users_to_groups']; However, it should also be noted that this depends on where you are attempting to use the model. Classes in the autoload config are not loaded until the Controller's constructor has been executed, so some hooks will execute before the model is loaded. |
Welcome Guest, Not a member yet? Register Sign In |