Welcome Guest, Not a member yet? Register   Sign In
Using libraries alongside models
#4

(03-29-2015, 06:13 PM)RobertSF Wrote:
(03-29-2015, 04:06 PM)mdixon18 Wrote: So here's conundrum, I have a home controller, In this controller I would like to store the latest products from the products controller. Now from the home controller I can't directly access the product controller.
Hi, Matt, and welcome to the forum!

I'll be the first to back down if my way isn't "best practices," but I don't consider controller, models, and views to be rigidly tied to each other. That is, I don't believe that you can load only the home model and no other model into your home controller. If I need to access products from my home page, I load the products model in my home controller and call the appropriate methods in that model.

I would not put methods that retrieve or manipulate products from and in the database in other models or libraries just to ensure that my home controller only loads the home model. That would place database access methods in different places, which I think would be worse practice than keeping them all together in the same model, regardless of which controller used them.

Thanks for this, I agree this is the way I would do it in the controller and pull them all in.

But what do you guys think about calling a model from a library? Only I've created a huge template library and it'll be really nice if its good standards to assign a mod specifically to a library.

I've done it this way already and hey it works.

But is it a good way of doing things?
Reply


Messages In This Thread
Using libraries alongside models - by mdixon18 - 03-29-2015, 04:06 PM
RE: Using libraries alongside models - by mdixon18 - 03-29-2015, 07:21 PM
RE: Using libraries alongside models - by RWCH - 04-03-2015, 07:17 AM
RE: Using libraries alongside models - by gadelat - 04-03-2015, 08:31 AM
RE: Using libraries alongside models - by RWCH - 04-07-2015, 03:44 AM
RE: Using libraries alongside models - by RWCH - 04-07-2015, 03:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB