You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 9, 2025. It is now read-only.
I think this method should instantiate a new DriverInterface instance instead of changing the internal PDO object state.
Consider the situation where multiple high-level classes depend on the same PDODriver instance, which was injected at the entry-point.
Changing database in one of those high-level classes will change database everywhere, because objects are always passed-by-reference. This will introduce an unexpected behavior.
However, this behavior cannot be achieved easily in current PDODriver state, because database name is a part of DSN, which is a string. The only way to implement this switchDatabase() method is to make DSN value object. Then we could re-use this DSN to make a new PDO connection inside DriverInterface::switchDatabase() method and return a new DriverInterface instance.
Then we could re-use this DSN to make a new PDO connection inside DriverInterface::switchDatabase()
We'd also need to store the username and password if we're attempting to reconnect. I was personally thinking of having DriverCollection since it seems wrong to have the Driver deal with juggling two connections
The text was updated successfully, but these errors were encountered: