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

[eluser]Michael Wales[/eluser]
Unfortunately, this could get kind of tricky, the way CI currently has models implemented. The model object doesn't really describe one instance of data (for example: one user). Instead, it describes one type of data, all instances of it.

For example, let's say you have a page in which you are listing 3 users. You don't instantiate the user model 3 times, loading their unique variables into class variables. Instead, the model is instantiated once and that same instance of the model is used to retrieve data as you see fit.

So, technically, yes it would be really easy to setup the Model class to accept constructor parameters but you would be severely limit in how that model would behave with our seriously planning ahead and probably changing the majority of your calls to models within your application.

I just finished this piece of the Datamapper ORM Class today and it was a bit of a headache... definitely takes a complete rethinking of CI's model class once you go in this direction.


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