How can i do multiple transactions on multiple databases?
$transactionManager = new TransactionManager();
$transactionManager->setDbService("db1");
$db1_tx = $transactionManager->get();
$transactionManager = new TransactionManager();
$transactionManager->setDbService("db2");
$db2_tx = $transactionManager->get();
$obj = new Obj();
$obj->setTransaction($db1_tx);
if(!$obj->save($_POST)){
$db1_tx->rollback();
}else{
$obj2 = new Obj2();
$obj2->setTransaction($db2_tx); //since it belongs to db2
if(!obj2->save($_POST)){
$db2_tx->rollback();
$db1_tx->rollback();
}
}
$db1_tx->commit();
$db2_tx->commit();
The above code does not work, it only hangs my mysql server