1
In a certain part of the system I need to do the transaction control, but this operation involves tables that are in different databases.
I made a test by inserting two tables in different banks and at the end of them making a rollback
, as expected this operation failed, the rollback
happened only on the first table.
Is there any way to control transactions given this scenario?
Remarks:
- I’m using Laravel.
- Both banks are mysql
The test I did contained the following code:
DB::beginTransaction();
Aluno::create(['nome' => 'teste']);
Professor::create(['nome' => 'teste2' ]);
DB::rollback();
In each model I have set one connection
different.
Are the two banks on the same server (communicating with each other)? The transaction is usually managed by connection, if you have two different connections I believe you will need to treat them separately and only commit one if the other is successfully committed (the rollback would also be done for each connection)
– Diego Rafael Souza
the banks are on the same server, but they are two different connections
– David Santos