Skip to content
stanistan edited this page Jun 2, 2011 · 1 revision

AQL has wrapper functions for ADODB's transaction methods.

If any AQL methods are called while in a transaction, errors will be suppressed so that the transaction can be rolled back. Otherwise, an E_USER_ERROR is triggered.

Methods:

aql::start_transaction()

Usage: Call aql::start_transaction() to start a transaction.

aql::complete_transaction()

Usage: Call aql::complete_transaction() to finish a transaction, or rollback if the transaction failed.

aql::fail_transaction()

Usage: Call aql::fail_transaction() when in a transaction to trigger failure. aql::transaction_failed() will return true.

aql::in_transaction()

Usage: aql::in_transaction() will return true or false based on if the query is being executed in a transaction.

aql::transaction_failed()

Usage: Will return true if a query failed inside the transaction.

Example:

aql::start_transaction();
aql::fail_transaction(); // trigger failure
...
   aql::insert(...);
   aql::update(...);
...
$failed = aql::transaction_failed();
aql::complete_transaction();

if ($failed) {
    echo 'Transaction Failed';
}