In modern databases, transactions also do some other things, such as ensuring that you can't access data that another person has written halfway. However, the basic idea is the same—transactions are there to ensure that no matter what happens, the data you work with will be in a sensible state. They guarantee that there will not be a situation where money is withdrawn from one account, but not deposited to another.
Yii2 supports a powerful transaction mechanism with savepoints.
A classic example is of transferring money from one bank account to another. To do that, you have to first withdraw the amount from the source account, and then deposit it to the destination account. The operation has to succeed in full. If you stop halfway, the money will be lost, and that is very bad. For instance, we have a recipient account and a sender account. We would like to transfer money from sender to recipient. Let's assume that we have an account model.