views:

38

answers:

1

When creating a CodeIgniter project, what is the best way to handle relations between models? Should models contain other models that they are related to, should this be handled in the controller, or is there some other way to handle these scenarios? I'm thinking about one-to-one, one-to-many, or many-to-many relationships.

example: let's say I have a blog post, which has a many-to-many with tags, and a one-to-many with comments. What would be best practices for getting the tags and comments when getting blog posts?

+2  A: 

Good question but there's no easy answer.

One project of mine uses a lot of database joins in its queries. So the correspondence is more one controller to one model, and that model then calls on a bunch of different tables.

Summer