Reputation: 267177
I have lots of code in models, and although the model might be loaded elsewhere, I like to make sure by doing $this->load->model()
almost everywhere its used. Is that all right, or does it use up any resources; even if the model has already been loaded?
Upvotes: 2
Views: 2146
Reputation: 29514
Its better to load the model in the constructor.so tat no need to repeat the code again and again..
Upvotes: 1
Reputation: 929
The constructor will be executed every time you call $this->load->model(), but the file itself will be loaded only once. It might make sense to put your often-used model into application/config/autoload.php
Upvotes: 6