We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multi-transactions in different db-services

I want to insert ONE record into a db/table, and then insert ONE record into another db/table ... If any of the insert failed, both of them will be abandoned.

The problem is: Why do two different Pdo\Mysql objects share the same property "_transactionLevel" ?

If I begin a transaction with one db-servcie, other db-services can not do transactions if previous one is not commited or rollbacked.

So I think You can do only one transaction with one db-service, but it should not stop transactions with other db-services.

$conn1 = $this->getDI()->get('vs_hotel');
$conn1->begin();
$conn2 = $this->getDI()->get('vs_common');
$conn2->begin();
var_dump($conn1->isUnderTransaction());  // return true
var_dump($conn2->isUnderTransaction());  // return false

Thank you very much.