Welcome Guest, Not a member yet? Register   Sign In
Load model with a constructer - possible?
#6

[eluser]phpoet[/eluser]
Thank you, Michael, for all of your insight into this. I really appreciate it. I completely agree that loading the model, then just ignoring that object is ugly.

If all Models are Singletons, what is the best way to work with classes that you don't want to be Singletons but do interact heavily with the database? Perhaps the idea is to create "Library" classes and call get_instance() to gain access to the CI resources. Normally I think of Library classes as those classes which are reusable among projects rather than classes designed to work with project specific data. I suppose you could simply create project specific Libraries. This is not how I normally think of an MVC framework though. I think of M as Models.

In your CI Applications do you write initialize() or load() functions that take the id (primary key) from the db table as a parameter and then pull in the data? So do you have a lot of code in your applications that looks like this?

Code:
$this->load->model('User');

$this->User->load(4);
echo $this->User->username;

$this->User->load(5);
echo $this->User->username;


Messages In This Thread
Load model with a constructer - possible? - by El Forum - 08-26-2008, 02:42 PM
Load model with a constructer - possible? - by El Forum - 08-27-2008, 01:58 PM
Load model with a constructer - possible? - by El Forum - 08-27-2008, 02:27 PM
Load model with a constructer - possible? - by El Forum - 08-27-2008, 03:08 PM
Load model with a constructer - possible? - by El Forum - 08-27-2008, 11:05 PM
Load model with a constructer - possible? - by El Forum - 08-28-2008, 08:08 AM
Load model with a constructer - possible? - by El Forum - 08-28-2008, 09:58 AM
Load model with a constructer - possible? - by El Forum - 08-28-2008, 12:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB