Welcome Guest, Not a member yet? Register   Sign In
Using model in a model
#16

[eluser]BrianDHall[/eluser]
@oribani - The only thing I don't understand is how CI is limited, limiting, or fails in some way to support inter-model communication? People incorrectly refer to get_instance() as a hack - it's a very useful, and necessary, feature for any OOP-style framework like CI.

I must agree on Models though, people are concerned with CRUD so much they tend to forget there are other reasons for models to exist. Having an ORM helped me with this, simply because I had this whole empty model that automagically could handle CRUD and all that, so now what was I suppose to do with this model anyway?

What I think is missed is that Models should fully represent the data they are responsible for, including having the brains to know how to deal appropriately with certain manipulations. For instance for a Payment model it should not just know how to store transaction data, but rather should have all CRUD functionality AND be able to intelligently process payments, record the results, and pass on the resulting events to other models and/or back the controller.

So for instance you want to delete a user in a forum - what do you do with their posts? If you want to do a user->deep_remove(), the only logical place to build such functionality is in the user model - where else would you want to put it?

Its a beginners notion to try to put everything in the controller and leave only dumb functions to views and models. Now I see everything should be intelligent - everything has its own mission and requirements, as views 'can' be more than mere templates, and models can be more than CRUD.


Messages In This Thread
Using model in a model - by El Forum - 01-25-2008, 03:09 AM
Using model in a model - by El Forum - 01-25-2008, 03:32 AM
Using model in a model - by El Forum - 01-25-2008, 03:32 AM
Using model in a model - by El Forum - 01-25-2008, 03:40 AM
Using model in a model - by El Forum - 01-25-2008, 03:49 AM
Using model in a model - by El Forum - 01-25-2008, 03:52 AM
Using model in a model - by El Forum - 01-25-2008, 03:56 AM
Using model in a model - by El Forum - 01-25-2008, 11:37 AM
Using model in a model - by El Forum - 01-25-2008, 03:33 PM
Using model in a model - by El Forum - 01-25-2008, 04:07 PM
Using model in a model - by El Forum - 01-25-2008, 04:22 PM
Using model in a model - by El Forum - 01-25-2008, 07:44 PM
Using model in a model - by El Forum - 09-20-2009, 09:20 PM
Using model in a model - by El Forum - 09-20-2009, 09:43 PM
Using model in a model - by El Forum - 09-21-2009, 10:53 AM
Using model in a model - by El Forum - 09-21-2009, 11:12 AM
Using model in a model - by El Forum - 09-21-2009, 01:12 PM
Using model in a model - by El Forum - 09-22-2009, 07:24 PM
Using model in a model - by El Forum - 10-03-2009, 02:09 PM
Using model in a model - by El Forum - 05-21-2013, 09:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB