-
Notifications
You must be signed in to change notification settings - Fork 471
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
PHP DB code: clean up the logic, and allow for > 1 readonly replica #5697
Conversation
Please, use atomic commits so that one can review separate topics separately. |
Apart from the above I like the approach. Flexible while not overly complex. |
Remove the 'use $db_name' query; don't need that with mysqli
I removed the 'use db_name' query (not needed with mysqli) |
@bema-aei should ultimately review this as well (I can't add him). |
This works fro us in principle, with the change I mentioned above. I updated my original branch with your changes, with two important changes:
Please have a look at that branch. |
- a close() method, closes the connection - a $dbnum member: which replica you're connected to (0 if main DB) Also, BoincDb doesn't inherit DbConn.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5697 +/- ##
============================================
- Coverage 10.53% 10.53% -0.01%
Complexity 1068 1068
============================================
Files 279 279
Lines 35874 35891 +17
Branches 8412 8417 +5
============================================
Hits 3780 3780
- Misses 31700 31717 +17
Partials 394 394 |
First of all I like the idea of allowing an arbitrary number of replicas. And thank you for implementing a close() function. This code in get() is still unchanged, i.e. if $instance is set, get() will return the same instance even if $dbnum is different. At least this doesn't correspond to what I proposed in my branch. Is the "user" of this code required to close one connection / instance before opening another? If so, it should be noted somewhere, I didn't expect that. |
Also too I there is an uncaught exception if the DB connection is refused for some reason. I get:
|
|
if open to different dbnum, close and reconnect. Don't throw exception if connect fails
Thanks, this works for us technically. We do use a recent MariaDB, which has some defaults different from MySQL, hence the exception. However, for reasons I pointed out already I can't really approve the first commit which combines different features w/o even mentioning in the commit message, so I can't recommend to merge this branch as it is. |
How does a PHP module's ( |
Oh. Sorry, was mislead. Indeed, that's the mysqli config. |
Also always use mysqli interface