-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adopt PDO for database access #513
Comments
An interesting tutorial: https://www.sitepoint.com/re-introducing-pdo-the-right-way-to-access-databases-in-php/ |
A lesson learned when coding the first patches: if we want to use I already attempted to match column names in the query with the internal properties in the VOs using AS like |
Merge pull request #534 from Igalia/i513-pdo-for-template-table
Reviewed in PR #534:
|
Merge pull request #539 from Igalia/i513-pdo-for-settings-table
From #539:
|
Merge pull request #551 from Igalia/pdo-customer
Merge pull request #553 from Igalia/pdo-sector
Reviewed in #551:
Reviewed in #553:
|
Merge pull request #560 from Igalia/pdo-area
Reviewed in PR #560:
|
Merge pull request #575 from Igalia/pdo-extra-hour
Merged in #575:
|
Merge pull request #606 from Igalia/pdo-city-dao
As part of PR #608, the create operation in ProjectDAO was migrated:
|
In PR #614 I migrated the delete operation in ProjectDAO:
|
We had a specific operation in the backend to update only certain fields of a project, but the UI was always sending the full project data. We think the ability of updating only some fields of the project is not important, and we prefer to minimize the amount of code to maintain. So we have: * Switched the web service to the previously unused UpdateProjectAction and ProjectDAO::update. * Modify ProjectDAO::update to detect specific errors and return an OperationResult, just like the partialUpdate operation did. * Modify ProjectDAO::update to use PDO. * Remove all code related to PartialUpdateProject.
We had a specific operation in the backend to update only certain fields of a project, but the UI was always sending the full project data. We think the ability of updating only some fields of the project is not important, and we prefer to minimize the amount of code to maintain. So we have: * Switched the web service to the previously unused UpdateProjectAction and ProjectDAO::update. * Modify ProjectDAO::update to detect specific errors and return an OperationResult, just like the partialUpdate operation did. * Modify ProjectDAO::update to use PDO. * Remove all code related to PartialUpdateProject.
In PR #615 I migrated update operations in ProjectDAO:
|
Merged in #618:
|
PHP Data Objects (PDO) define a consistent interface for accessing databases in PHP: https://www.php.net/manual/en/intro.pdo.php.
It can access different database providers with the same interface, saving ourselves the hassle to code DB access different implementations with
pg_*
ormysql_*
methods if we need to support multiple backends.More importantly, PDO provides a defense against SQL injection using parameter binding for DB queries. We currently have some protections using the DBAdapter code that we imported from the Propel project, but we must not forget to use them when coding queries and we probably failed to do so here and there.
Let's figure a way to adopt PDO incrementally in our code base!
The text was updated successfully, but these errors were encountered: