I am modifying the model class by completely replacing it. I also wanted to break most of the components in different classes and to be loaded when they are needed. This particular class has to be loaded in the constructor. A simple model of my classes is as follows:
Model.php
class CI_Model {
function __construct(){
load_class('Model_validations', 'core');
}
}
Model_validations.php
class CI_Model_validations extends CI_Model {
private $validations = array();
public function validates($field){
}
}
What I get from the following program is this:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in /xampp/htdocs/cms/system/core/Controller.php on line 233
Additionally I tried to remove extends CI_Model and it works just fine.
Also we can say that the CI_Model_validations::validate() method is called immediately after loading but it’s empty and I don’t see how that could cause the problem.
Any ideas?
Thanks in advance.
This is because CI_Model tries to load CI_Model_validations which tries to load CI_Model again as it inherits from it. And CI_Model tries to load CI_Model_validations again and so on …
UPDATE: My assumption above seems wrong from this answer. It says that load_class is a singleton loader.