- v5:userguide:learn_multidatabase:connections|Multiple Connections ^ v5:userguide:userguide_index|List Of Tutorials ^ ->
~~NOTOC~~
====== Synchronizing Transactions ======
In databases that support transactions, we can use smart transactions to synchronize the transactional status of multiple connections.
Note that the commonly used table format **//MyIsam//** in MySQL is not a transactional table and cannot be controlled in this way.
include 'adodb/adodb.inc.php'; # load code common to ADOdb
$conn1 = adoNewConnection('mysqli'); # create a mysql connection
$conn2 = adoNewConnection('oci8'); # create a oracle connection
$conn1->connect($server, $userid, $password, $database);
$conn2->connect(false, $ora_userid, $ora_pwd, $oraname);
$conn1->startTrans();
$conn2->startTrans();
$conn1->Execute('insert ...');
$conn2->Execute('update ...');
We now check the status of both connections using the [[v5:reference:connection:hasFailedtrans|hasFailedTrans()]] method before committing the transaction. This will indicate if any of the executed statements has failed to complete.
if (!$conn1->hasFailedTrans()
&& !$conn2->hasFailedTrans())
{
$conn1->completeTrans();
$conn2->completeTrans();
}
**End Of Lesson**