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
WIP - Database refactoring #12862
base: develop
Are you sure you want to change the base?
WIP - Database refactoring #12862
Conversation
nupplaphil
commented
Mar 2, 2023
- For Addon pre-loaded capability
- Making Datbase results "object oriented"
- Either a IDatabaseResult or a IDatabaseError returns
- encapsulates all "statement" based calls into the corresponding Result-object (fetch, affected rows, ...)
- Splits PDO and MysqlI driver specific namespaces
- Preparation for new Driver specific classes (postgresql?)
- For Addon pre-loaded capability - Making Datbase results "object oriented" - Either a IDatabaseResult or a IDatabaseError returns - encapsulates all "statement" based calls into the corresponding Result-object (fetch, affected rows, ...) - Splits PDO and MysqlI driver specific namespaces - Preparation for new Driver specific classes (postgresql?)
Postgre hell yeah! |
Please keep in mind that other databases like PostgreSQL should be connected via PDO. So a MySQL PDO and a PostgreSQL PDO will have most code in common. The differences are at the places where we create the SQL command (since PostgreSQL uses a different way to escape table names and field names. So possibly it would be an idea, to complete drop MySQLi and to work solely via PDO. |
Ok, so we would have just one driver (pdo) and stick to it. As far as I read about PDO, it could enable support for other DBMS as well, but, as you said, there are language specific differences Shall I proceed with PDO only? The origin intention was to proper separate the core from our Thus the execution flow would be:
The last one was the orignal goal of this PR and lead to this change g |
I would like to know @MrPetovan's opinion about this as well. Also we should ask in the forum if admins are using PDO or MySQLi. |
I'm not familiar enough with PostgreSQL to know the caveats of using PDO to interface with it. Otherwise, I'm not happy with the naming, I feel like |
The naming and the whole PR is highly WIP so we can discuss about it :-) And fullDatabase was just a working title.. I'm with you about the naming suggestions and will follow it when adapting it |
a complete different question .. Why don't we use a tiny, lightweight but fast library like https://github.com/ezSQL/ezsql which supports all kind of databases .. This would reduce this work massively .. Did we already talk about such thing? Shall I start a discussion in our board? At least the syntax of this library seems like understandable and almost identically to how we use it. |
The simple answer is that any significant change in the way we perform queries will incur a massive migration cost which has so far stymied any discovery efforts in this domain. |
I see 60
It seems like a more direct way than checking 60 places if they are PostgreSQL compatible and fixing them step by step :) |
Wow, I didn’t expect so few instances left of the freeform queries, I guess we have been effective refactoring the modules. We should finish this sometimes. |
In the last years I replaced most of the direct calls step by step with more high level calls. Much of this was done by now working a lot with views. Concerning that library: I had a short glance at it. I haven't found anything that could help with our system of having a file like I had a look at the functions to alter the table structure. But it seems like these calls simply are some wrapper around the calls. There is no checking for the existing database structure for example. Means we will need the whole functionality in Also I just saw that that other library doesn't seem to support the creation of views - which we really use a lot. Also comments like this doesn't sound promising:
|
Ok I understand: stick to the plan :-) Thanks for your explanation and insights about the necessary functionality |
Concerning PDO or MySQLi: I asked the admins in post https://forum.friendi.ca/display/ec054ce7-3264-0227-d9e1-be3580203355. it seems as if everyone uses PDO. So possibly we could stick to it and should only vary in nuances between MySQL and PostgreSQL. |
$timeout = 20; | ||
|
||
do { | ||
$result = $this->readInternal($sql, $parameters, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$result = $this->readInternal($sql, $parameters, false); | |
$result = $this->writeInternal($sql, $parameters, false); |
I'd be up for creating a test instance running Postgres :) |
In case this PR shall be part of the 2023.09 (10) release, please redirect it towards the 2023.09-rc branch. |