Model within a model |
(06-29-2021, 12:31 PM)LuxesR Wrote: Is it possible to include a model in the '__construct' and do the same with the other model? because it will create infinite loop. like picture in picture in two mirror sided each other..
That is not a good practice. However, to get past your current situation, you can do lazy loading of the needed models. That is, you do not load them on the needing models' instantiation. You can do something like this.
PHP Code: class Settings_model extends \App\Models\BaseModel
Okay. It looks like that this is not an option what I'm asking. But how about I include the model every time there is a new function inside a model? Is this oke or will it also eventually give a memory leak if there are to many?
For example like this: PHP Code: namespace App\Models; PHP Code: namespace App\Models; I know that this means that it includes a model everytime in every function, but at least I can get the application running on CI4 and I can fix parts in the future. By the way, why is the autoload for models from CI3 gone? I have some applications having a lot of models inside the autoload and it still runs really fast. You did not even notice it when loading it. |
Welcome Guest, Not a member yet? Register Sign In |