As Title said, and see codes below:
<?php
try {
        $transaction = $manager->get();
        $modelA = new FooModel();
        $modelA->setTransaction($transaction);
        $modelA->a = "xxx";
        $modelA->b = "yyy";
        if($modelA->save() == false) {   // use $transaction->getConnection() to do the save operation
            $transaction->rollbak();
        }
        $modelB = new BarModel();
        $modelB->setTransaction($transaction);
        $modelB->a = "xxx";
        $modelB->b = "yyy";
        if($modelB->save() == false) { // use $transaction->getConnection() to do the save operation
            $transaction->rollback();
        }
        $count = FooModel::count();  // What conneciton would this line use???
        $transaction->commit();
} catch(TxFailed $e) {
    // ...
}
return $count;
Someone would say, you can do the calculating after the transaction. Yes, I can. But I splite read and write connection in my app. There is lantency between master and slaves.
So, is there a good way to do this work?