Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
One to Many Tables with ORM
  • I'm sure this is a dumb and/or simple question, but if I am using the default ORM package with fuel and I have a bunch of database tables that are linked by "one to many" tables (ie: properties being tied to multiple pages) what is the best way to handle with this models? In CI I would have just made a generic model for "pages" and joined all the relative tables within that model. With fuel I am using a real ORM solution and I'm not sure if I should be generating a model for these tables or handling them some other way? Is there a best practice?
  • http://docs.fuelphp.com/packages/orm/relations/has_many.html You create 2 models: page en property. The model 'page' has_many properties and the model 'property' belongs_to page. If you mean many to many (when you have some standard properties and a some of those properties belong to a page), you have to create an extra table pages_properties and set up a many to many relationship in the models. Unfortunately FuelPHP's ORM does not support a combination of foreign keys as the primary key, so you have to add a specific primary key column in that table.
  • Thanks Peter, Just found my way to the Introduction to Relations and have been trying to make sense of it all!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion