My_Model don't auto Load by Core/Loader |
Hello,
I use Code Igniter 3.0.4 and I have a class MY_Model.php in repository application/core/ but when i call a model, the class MY_Model don't load. With Code Igniter 3.0.0 this isn't not a bug ! I saw in the file /system/core/Loader.php at line 315 and there is the expression "require_once .... " but not the expression new $class(); with in $class = "MY_Model" I added to the line 320 and it goes ! Code: $CI->$class = new $class(); Can you take into account this modification for next release of Code Igniter 3 ?
No, it's not supposed to be instantiated. See this bug report: https://github.com/bcit-ci/CodeIgniter/issues/4350
And to clarify further: MY_Model ("MY", not "My" - this is important) is getting loaded, contrary to your claim ... I suppose you mean something else.
File : application/core/MY_Model.php
Code: class MY_Model extends CI_Model On CI V3.0.0 I have the message "MY_Model Class Initialized" in the log.txt On CI V3.0.4 I haven't this message, but with my code in system/core/Loader.php that's fine ! ?? Thanks !
You shouldn't need the MY_Model class to be instantiated in order for things to work properly. Whatever class extends MY_Model should simply call the parent::__construct() method in its constructor (if the constructor is defined) just as you have done in your MY_Model constructor.
Further, you shouldn't need to call get_instance() in MY_Model, since CI_Model defines a __get() method which does this for you. If you removed the definition of the $commun property from MY_Model, calling $this->commun = $this->load->database('commun', true, true); should do the same thing that you seem to be trying to do with the rest of the code in your constructor. |
Welcome Guest, Not a member yet? Register Sign In |