Changes

m
Line 318: Line 318:  
Do not include the IF into your forged SQL request. But use instead $db->ifsql() method to you will make a SQL IF that is compatible with all SQL databases.
 
Do not include the IF into your forged SQL request. But use instead $db->ifsql() method to you will make a SQL IF that is compatible with all SQL databases.
    +
*No DELETE CASCADE and ON UPDATE CASCADE
 +
Such instruction are forbidden because they bypass the business rules. 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. So all business rules must be implemented on the same side (the server PHP side), this is the reason why business rules implemented on Database are not allowed (same situation than for Database triggers)
    
==Using Database triggers==
 
==Using Database triggers==