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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With