Closed Faryshta closed 8 years ago
ACID is a characteristic of DBMS so I'm not sure what's the purpose of doing all that if you don't really need that. Don't think it would be a good idea for a recipe.
with the definition it uses we can say that a web application is a DBMS since we are managing a database using a web application and the more operations used the more important is that your operations are ACID.
For example transferring money from an account to another, selling articles online, deleting all related records of a user before deleting the user.
All those things
OK, seems I don't understand something about your initial idea. Do you want "Using database transactions" recipe?
how about 'using database transaction for multiple operations'?
OK. So that's more introductory topic to using DBMS transactions than any new concept, right? Fine then.
A guide on how to follow https://es.wikipedia.org/wiki/ACID
I teach my coworkers that to use ACID the following steps should be meet.
1) Validate user permissions to execute an operation (usually by controller and action filters like RBAC)
2) Load data
3) Start transaction preferably with
Transaction::SERIALIZABLE
4) Validate all loaded data.
4.1) If any of the validations fails execute
rollBack()
and stop the operation4.2) Show render view to the user to show errors
5) Save all data in order and assigna newly defined id's.
5.1) In case of exception execute
rollBack()
and stop the operation5.2) Throw the exception to the user so yii2 can handle it
5.3) Readjust your validation rules if possible so that exception is not thrown again and instead the validation fails and show an error to the user.
6) execute
commit()
Would this be good for a recipe?