Open lalande21185 opened 4 weeks ago
This hugely depends on the backend, so it can't be implemented in a generic way, AFAIK.
I see it supports MySQL, SQLite, Oracle, Sql Server, PostgreSQL and IBM Db2. My understanding is that as long as transactions are supported, then read-only transactions are supported for each database. So if you can do beginTransaction
you should be able to do something like beginReadOnlyTransaction
.
I cannot be sure yet without trying. I could give it a go and if it just does not work, then I leave it.
RFC
Add support for read only transactions. Currently you can start a transaction with
beginTransaction
. The proposal would add abeginReadOnlyTransaction
method that starts a read-only transaction.Goal
Provide a method to start a read-only transaction. The proposed name for the method is
beginReadOnlyTransaction
.Background
I experienced a use case where I needed a read-only transaction. While it is easy enough to do it with the existing library. We can make it easier with a ready-to-use method that is well tested.
Considerations
There is no required preparation for
laminas-db
users. The change does not break anything.Proposal(s)
Users will use the method
beginReadOnlyTransaction
when wanting to start a read-only transaction. Everything else stays the same.Appendix
First, add the method
beginReadOnlyTransaction
toLaminas\Db\Adapter\Driver\ConnectionInterface
. Then implement the method in each driver. Finally, make sure the new code is covered with tests.I welcome all questions and feedback on the proposal.