Database Abstraction Layer for PHP

User Tools

Site Tools


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/';  # 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->Execute('insert ...');
$conn2->Execute('update ...');

We now check the status of both connections using the hasFailedTrans() method before committing the transaction. This will indicate if any of the executed statements has failed to complete.

if (!$conn1->hasFailedTrans()
&& !$conn2->hasFailedTrans())

End Of Lesson

v5/userguide/learn_multidatabase/transactions.txt · Last modified: 2017/04/18 11:06 by dregad