Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
ORM subsequent delete, save model actions participating in same transaction
felixalbani
April 2015
Is it possible to have delete and save model actions participating in same transaction?
I have a situation when I need to delete some rows of a has_many related model
unset($order->order_detail[$k]);
$value->delete(null, true);
later on have a
$order->save(null, true);
will those 2 participate or not in same transaction, how do I make them participate in same transaction?
Harro
April 2015
Accepted Answer
If you unset a related child object, and you subsequently save the parent, those related objects will be unlinked from the relation, but not deleted.
If you want to delete them, you need to delete them seperately.
If you want multiple ORM actions in a single database transaction, you can use
DB::start_transation() / DB::commit_transaction() / DB::rollback_transaction()
to wrap them into a single transaction. Obviously, you need to capture errors from the ORM actions manually to do a proper rollback if needed.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
April 2015