Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM not saving relations
  • Hi!
    I'm currentky rewriting my application to use ORM, but while I already understood most of the principles I solve this issue.
    I have 2 models: "Customer" and "Customer_Company". Which are related in a one-to-one relation. which I believe is set up right. However when saving the customer even though the company is created and the customer is saved, the relation isn't saved in the database.
    The models - here
    And my db structure - here

    Could anybody help me please?
  • HarroHarro
    Accepted Answer
    The relation definition should be the other way around.

    Easiest to remember: the model that contains the Foreign Key (here: Customer) has the belongs_to() side of the relation definition.

Howdy, Stranger!

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

In this Discussion