I am pretty sure if you don't use rollback then after so many tries and exception will be thrown anyway.
What happens when i don't rollback or commit a transaction?
I have a simple doubt. If i use DB::beginTransacion, and then DB::commit() when success, but no DB::rollback(), in case fails. What happens with the transaction when the application fails? Laravel will auto rollback the transaction for me if an exceptions is thrown? Someone told me that, but i can't confirm this information any where.
@Niush I found the answer in documentation after all. If i use DB::transaction, Laravel will do the rollback for me. But with DB::beginTransaction() i need to do DB::roolback() by myself.
https://laravel.com/docs/9.x/database#database-transactions
If an exception is thrown within the transaction closure, the transaction will automatically be rolled back and the exception is re-thrown. If the closure executes successfully, the transaction will automatically be committed.
Please or to participate in this conversation.