Search code examples
phpdatabaseperformancecodeigniterconnection

Codeigniter: Will using $this->load->database() multiple times result in multiple connections?


I was thinking about removing the database library from my autoload file. I am caching everything on the page so I do not need to connect to the db every time and I figured it is a waste of speed if I have CI connect to the db anyway.

My Question is now: if I for e.g. load the database in MY_Model $this->load->database() without parameters (they come from the config file), will a new connection be established for every model I use in a controller?

Or will it be like helpers that are only loaded once?


Solution

  • They only get loaded once. The database class makes sure of that for you.