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

(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.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply


Messages In This Thread
Using libraries alongside models - by mdixon18 - 03-29-2015, 04:06 PM
RE: Using libraries alongside models - by RobertSF - 03-29-2015, 06:13 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