Language and development rules: Difference between revisions

Jump to navigation Jump to search
m
Tags: Mobile edit Mobile web edit
Tags: Mobile edit Mobile web edit
Line 325: Line 325:
* No DELETE CASCADE and ON UPDATE CASCADE
* No DELETE CASCADE and ON UPDATE CASCADE


Such SQL instructions are forbidden because they bypass the business rules of the application bringing a lot of troubles out of control of the developers. For example, if there is a delete cascade between table A and B, when the application will execute the code to remove a record in A, the children into table B will also be removed. If there was a Dolibarr PHP trigger (for example bring by an external module) on the deletion of record of B (for example to validate the deletion or to execute a complementary action), the DELETE CASCADE will be executed without having the Dolibarr PHP trigger executed, missing the validation or actions of the PHP trigger of the module. All business rules must be implemented on the same side (so the server PHP side), this is the reason why business rules implemented on Database side are not allowed (same conclusion than the next point about Database triggers)
Such SQL instructions are forbidden because they bypass the business rules of the application bringing a lot of troubles out of control of the developers. For example, if there is a delete cascade between table A and B, when the application will execute the code to remove a record in A, the children into table B will also be removed. If there was a Dolibarr PHP trigger (for example bring by an external module) on the deletion of record of B (for example to validate the deletion or to execute a complementary action), the DELETE CASCADE will be executed without having the Dolibarr PHP trigger executed, missing the validation or actions of the PHP trigger of the module. All business rules must be implemented on the same side (so the server PHP side), this is the reason why business rules implemented on Database side are not allowed (same conclusion than the next point about Database triggers).
Note that external modules can use them for links between Dolibarr tables and its module tables but a better recommanded solution is to use the trigger to implement the deletion of its table when a record of a parent official table is deleted.


==Using Database triggers==
==Using Database triggers==

Navigation menu