Welcome Guest, Not a member yet? Register   Sign In
Not grokking models, please help
#3

[eluser]tunesmith[/eluser]
I am pounding my head against the same problem. Right now I have a scheme that looks like:

Code:
$this->load->model('UserModel');
$user = new UserModel;
$user->getByID($userid);
$user->firstname = "Blah";
$user->update();

This is proving not to be ideal for several reasons. First of all, the $user variable is huge, full of all the codeigniter internals, and when you have an array of user objects, that gets frightening. Second, there's the wasted object, like you mention. Third, the model itself is wordy, including a routine that populates itself (its vars) from the results of the sql queries.

For that I'm considering switching back to the more approved away of doing things, but I don't like the feeling that it is encouraging me to devolve. The fact is that my webapp requires database entities that then contain several other database entities, and I'm used to structuring those as objects that have arrays of other objects. I'm not sure where to define these objects, since I want to keep the controller layer free of business logic - it seems an alternative approach would be to have a library for each model that would do the assembly somehow, and then pass those objects into the model layer, but I haven't really experimented with that yet.


Messages In This Thread
Not grokking models, please help - by El Forum - 07-18-2010, 02:59 PM
Not grokking models, please help - by El Forum - 07-19-2010, 07:14 AM
Not grokking models, please help - by El Forum - 08-02-2010, 08:45 PM
Not grokking models, please help - by El Forum - 08-03-2010, 12:58 AM
Not grokking models, please help - by El Forum - 08-03-2010, 01:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB