PHP | MYSQL | Nested PDO::beginTransition() and PDO::commit() on different DBs

Im facing up a doubt: what happen if i disable autocommit for 2 different connections to 2 different databases, in a nested way?

Example code:

 $conn = new MainDB(); // DB class
 $conn_second = new NotMainDB(); // another DB class

try {

    $conn->dbh->beginTransaction(); // disable autocommit
    $conn_second->dbh->beginTransaction(); // disable autocommit on 2nd DB

    $run = $conn->dbh->prepare(/* UPDATE STATEMENT */);

    $run = $conn->dbh->prepare(/* ANOTHER UPDATE STATEMENT */);

    $ssp = $conn_second->dbh->prepare(/* AN INSERT STATEMENT ON ANOTHER DB */);

} catch (Exception $ex) {


is there anything i have to take care of? anyone already experienced such a case?


Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.