Welcome Guest, Not a member yet? Register   Sign In
1 controller = 1 model VS. 1 controller = multiple model

(08-30-2018, 11:41 AM)skunkbad Wrote:
(08-28-2018, 09:25 PM)albertleao Wrote:
(08-27-2018, 05:11 PM)skunkbad Wrote: So then how do you handle joins?

Mostly in libraries.

In my workflow, if the join is pulling in child data, I use a function within the parent model. For example, if you have 1 blog post with 10 tags, I'd have a function called 'tags()' in my BlogPost model that I could call to get related data.

I do have some models with join statements but I try to keep them as clean as possible. Keeping separation can make a huge difference down the road if your app gets big.

To illustrate what you would do, how about something like this:

ON A.id = B.a_id
WHERE A.foo = "bar"

I'm aware of how joins work, I'm just saying that most of mine are in libraries.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!

Messages In This Thread
RE: 1 controller = 1 model VS. 1 controller = multiple model - by albertleao - 09-04-2018, 08:11 AM

Theme © iAndrew 2016 - Forum software by © MyBB