Welcome Guest, Not a member yet? Register   Sign In
Calling a model from another model?
#25

[eluser]Unknown[/eluser]
[quote author="Randy Casburn" date="1214780514"]

It appears from looking at the CI internals that CI was designed with the idea that your Model functionality would be consolidated _functionally_ within a single file. That doesn't mean that you cannot use multiple Model files. Some times one might call multiple model files from the Controller and consolidate the data in the Controller prior to sending it to the View for example. But now I'll get flamed for breaking MVC because of the cloudy delineation between Model and Controller (academically). Either way, it seems CI prefers you to consolidate the data gathering routines into a single file. Then CI expects you to call that single Model to gather your data so you can deliver that data to your View.

That means all the dependency you've created here (and segregated into separate files) is expected to be in a single file from CI's perspective.

So here is the question. Do you ever use these classes or the functionality found in them independently of one another? Are they 'generally' used together and rarely used separately. If this is the case, then you've substantiated the CI design principles. Right? You should probably combine the functionality into a single class and be done with the problems this is causing you. Then consider this in future designs.

If they are always used independently, then consider that in future designs too. Knowing that you'll have to take special care to make the CI object available inside you're additional class structures.

We all do it both ways depending on the nature of what we are doing. I will tell you, though, given what I know, and nothing more, of this situation, I would consolidate this Model into a single class unless it is completely unwieldy. I would also consider the Outer Joins as a separate specialized DB class of sorts. But that's because I tend to consolidate my queries as much as I can.

Hope this is helpful.

Randy[/quote]

I jump into the conversation as I have the exact same problem the author has.
Before going deep into my questions, be aware that I'm an old school programmer who has learned Java like 8 years ago and I've never used MVC before.
Putting everything in a single controller is perhaps how we should use MVC, but it does not look very OOP to me. Shouldn't we separate as much as possible the different layers, ie having as many models as we have "object" in our database model?
If so, we can not put everything in one single file, and thus we need to have a lot of models, and call those models in other model to have the good hierarchy.


Messages In This Thread
Calling a model from another model? - by El Forum - 06-22-2008, 07:12 PM
Calling a model from another model? - by El Forum - 06-22-2008, 08:31 PM
Calling a model from another model? - by El Forum - 06-22-2008, 08:35 PM
Calling a model from another model? - by El Forum - 06-22-2008, 09:21 PM
Calling a model from another model? - by El Forum - 06-22-2008, 11:28 PM
Calling a model from another model? - by El Forum - 06-22-2008, 11:36 PM
Calling a model from another model? - by El Forum - 06-23-2008, 04:15 AM
Calling a model from another model? - by El Forum - 06-23-2008, 04:36 AM
Calling a model from another model? - by El Forum - 06-23-2008, 10:26 AM
Calling a model from another model? - by El Forum - 06-23-2008, 11:49 AM
Calling a model from another model? - by El Forum - 06-23-2008, 12:02 PM
Calling a model from another model? - by El Forum - 06-23-2008, 12:42 PM
Calling a model from another model? - by El Forum - 06-28-2008, 12:35 PM
Calling a model from another model? - by El Forum - 06-28-2008, 02:26 PM
Calling a model from another model? - by El Forum - 06-28-2008, 03:20 PM
Calling a model from another model? - by El Forum - 06-28-2008, 04:25 PM
Calling a model from another model? - by El Forum - 06-28-2008, 06:27 PM
Calling a model from another model? - by El Forum - 06-28-2008, 07:24 PM
Calling a model from another model? - by El Forum - 06-29-2008, 10:57 AM
Calling a model from another model? - by El Forum - 06-29-2008, 12:01 PM
Calling a model from another model? - by El Forum - 10-30-2008, 02:46 PM
Calling a model from another model? - by El Forum - 10-30-2008, 03:08 PM
Calling a model from another model? - by El Forum - 10-30-2008, 04:10 PM
Calling a model from another model? - by El Forum - 10-30-2008, 06:51 PM
Calling a model from another model? - by El Forum - 10-31-2008, 12:45 PM
Calling a model from another model? - by El Forum - 10-31-2008, 12:58 PM
Calling a model from another model? - by El Forum - 12-16-2009, 05:18 AM
Calling a model from another model? - by El Forum - 12-16-2009, 05:52 AM
Calling a model from another model? - by El Forum - 12-16-2009, 06:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB