Transaction in different banks

1

In a certain part of the system I need to do transaction control, but this operation involves tables that are in different databases.

I made a test by inserting two tables into different banks and at the end of them doing a rollback , as it was expected this operation failed, rollback happened only in 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 set a% w / o% different.

    
asked by anonymous 13.02.2018 / 13:56

1 answer

1

There's no way! Not even if your user has permissions on both banks and they are on the same server! What you can do in this case is to work with two different connections and treat them separately as needed. Here's a reference link .. Hope it helps! link

    
28.02.2018 / 22:23