Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Two Models, Parent/Child One form save at same time.
  • This seems like an easy enough question, but figured I would ask to make sure I understand it correctly.

    I have two models; Account and User. I have one form with fields for both models. I want the User to be a child of the Account model and a site visitor be able to fill out one form that creates both models with the associations. The account should be created and saved first while using that record's id as a key in the user table.

    Is there any sort of process I need to do to get the models/controllers setup right to rollback any commits made to the Account table if the insert of the User fails?

    Thanks.

  • With ORM, you can enable transactions by passing true as second parameter of the save() method.

    If you have defined the relation as 'cacade_save' (which is default), the save of the parent will save the child as well, within the same transaction.

Howdy, Stranger!

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

In this Discussion