Ali
Ali

Reputation: 267177

In CodeIgniter is It OK to use `$this->load->model( )` as Often as Needed?

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

Answers (2)

useranon
useranon

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

Related Questions