Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for read-only transactions #310

Open
lalande21185 opened this issue Aug 17, 2024 · 2 comments
Open

Support for read-only transactions #310

lalande21185 opened this issue Aug 17, 2024 · 2 comments
Labels

Comments

@lalande21185
Copy link

RFC

Add support for read only transactions. Currently you can start a transaction with beginTransaction. The proposal would add a beginReadOnlyTransaction method that starts a read-only transaction.

Q A
Proposed Version 2.21.0
BC Break? No

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 to Laminas\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.

@lalande21185 lalande21185 changed the title [RFC]: Support for read-only transactions Support for read-only transactions Aug 17, 2024
@Ocramius
Copy link
Member

This hugely depends on the backend, so it can't be implemented in a generic way, AFAIK.

@lalande21185
Copy link
Author

lalande21185 commented Aug 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants