CRM_Core_Transaction
class CRM_Core_Transaction
Constants
PHASE_PRE_COMMIT |
These constants represent phases at which callbacks can be invoked. |
PHASE_POST_COMMIT |
|
PHASE_PRE_ROLLBACK |
|
PHASE_POST_ROLLBACK |
|
Methods
Ensure that an SQL transaction is started.
Ensure that an SQL transaction is started.
No description
Immediately commit or rollback.
No description
Mark the transaction for rollback.
Execute a function ($callable) within the scope of a transaction. If $callable encounters an unhandled exception, then rollback the transaction.
Force an immediate rollback, regardless of how many any CRM_Core_Transaction objects are waiting for pseudo-commits.
No description
Determine whether there is a pending transaction.
Add a transaction callback.
Details
at line 113
static CRM_Core_Transaction
create(bool $nest = FALSE)
Ensure that an SQL transaction is started.
This is a thin wrapper around __construct() which allows more fluent coding.
at line 125
__construct(bool $nest = FALSE)
Ensure that an SQL transaction is started.
at line 129
__destruct()
at line 140
CRM_Core_Exception
commit()
Immediately commit or rollback.
(Note: Prior to 4.6, return void)
at line 151
static
rollbackIfFalse($flag)
at line 164
CRM_Core_Transaction
rollback()
Mark the transaction for rollback.
(Note: Prior to 4.6, return void)
at line 184
CRM_Core_Transaction
run(string $callable)
Execute a function ($callable) within the scope of a transaction. If $callable encounters an unhandled exception, then rollback the transaction.
After calling run(), the CRM_Core_Transaction object is "used up"; do not use it again.
at line 207
static
forceRollbackIfEnabled()
Force an immediate rollback, regardless of how many any CRM_Core_Transaction objects are waiting for pseudo-commits.
Only rollback if the transaction API has been called.
This is only appropriate when it is certain that the callstack will not wind-down normally -- e.g. before a call to exit().
at line 216
static bool
willCommit()
at line 224
static
isActive()
Determine whether there is a pending transaction.
at line 250
static
addCallback(int $phase, string $callback, mixed $params = NULL, int $id = NULL)
Add a transaction callback.
Note: It's conceivable to add callbacks to the main/overall transaction (aka $manager->getBaseFrame()) or to the innermost nested transaction (aka $manager->getFrame()). addCallback() has been used in the past to work-around deadlocks. This may or may not be necessary now -- but it seems more consistent (for b/c purposes) to attach callbacks to the main/overall transaction.
Pre-condition: isActive()