Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Try-Catch with DB Transactions

Premium
3 min read

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

LP
Luís Pedro Arede ✓ Link copied!

A question about using try-catch blocks:

What's the best approach, in your opinion? Wrap the DB::beginTransaction() inside try {} or put it outside the try{} block, just like the example?

M
Modestas ✓ Link copied!

It's better to have it outside in my opinion, but to be fair - it doesn't matter