How is thinkphp5 designed to use transactions?

is it better to put the transaction in the controller, or in the model, or is there another solution when using TP5 when you need a transaction? If you put it in a model, and multiple models are involved in the process, and the process requires a transaction, and the transaction in each model is successful, the transaction of the process will not be committed until it is successful. For example, the background administrator makes an operation, and if the operation is successful, the operation is written to the operation log. In the model of the operation, the transaction is successful, but when it is written to the log, it fails, and the whole operation is rolled back.

Mar.04,2021

1. When it comes to multiple models, you can just use the Db class
2. Log writes generally do not fail

Menu