Reputation: 3077
If I have reads/writes configured in database.php
, and I start a transaction like DB::transaction(function() { // series of reads and writes })
, will everything run on the write
connection, or will there be two separate transactions, or will it just explode?
Upvotes: 4
Views: 1397
Reputation: 594
https://github.com/laravel/framework/pull/3272
getReadPdo()
now checks if the query is within a transaction, and in that case returns the same PDO connection as the write.
Upvotes: 3
Reputation: 15780
If you're saying you want to do both reads and writes within a transaction using the same connection, then that will work fine - you can read from the database during the transaction.
If you're saying you want to read using one connection while you're writing as part of a transaction on the other connection, that will work fine too although you might have times when the read connection will block until the write connection transaction is finished.
Upvotes: 1