Welcome Guest, Not a member yet? Register   Sign In
New User - question on $this->load->database()
#1

[eluser]apodner[/eluser]

Hello all,

I am just trying out CI for the first time with any seriousness, and trying to move an existing app into the CI framework. I have shut off persistent connections, as I am not a fan of those.

I see where the manual suggests that the models you create extend the CI_Model class. In my app, multiple models could be instantiated in a single view, and I assume that if each model calls $this->load->database(), then I am creating multiple connections to the database in a single script execution, which I would prefer to not do.

It seems like less overhead to call the database connection in the controller and inject it into each model as a constructor parameter when the model(s) is instantiated.

My question is, am I losing anything by not extending the CI_Model class? I suppose it really doesn't matter since CI_Model does not appear to automatically create a connection to the database anyway, so the dependency injection would work either way.

Just wanted to see what veteran users are doing and if you all have any tips or suggestions regarding this.

thanks in advance


Messages In This Thread
New User - question on $this->load->database() - by El Forum - 11-21-2012, 09:16 PM
New User - question on $this->load->database() - by El Forum - 11-21-2012, 10:14 PM
New User - question on $this->load->database() - by El Forum - 11-22-2012, 05:36 AM
New User - question on $this->load->database() - by El Forum - 11-22-2012, 06:15 AM
New User - question on $this->load->database() - by El Forum - 11-22-2012, 06:18 AM
New User - question on $this->load->database() - by El Forum - 11-24-2012, 02:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB