interface TransactionManager

Represents an object that is capable of controlling transactions.

The TransactionManager might be the database connection itself, calling queries to orchestrate transactions, or a connector such as the PDOConnector.

Generally speaking you should rely on your Database object to manage the creation of a TransactionManager for you; unless you are building new database connectors this should be treated as an internal API.

Methods

bool
transactionStart(string|boolean $transactionMode = false, string|boolean $sessionCharacteristics = false)

Start a prepared transaction

bool
transactionEnd()

Complete a transaction

bool
transactionRollback(string $savepoint = null)

Roll-back a transaction

transactionSavepoint(string $savepoint)

Create a new savepoint

int
transactionDepth()

Return the depth of the transaction For unnested transactions returns 1 while in a transaction, 0 otherwise

boolean
supportsSavepoints()

Return true if savepoints are supported by this transaction manager.

Details

at line 26
bool transactionStart(string|boolean $transactionMode = false, string|boolean $sessionCharacteristics = false)

Start a prepared transaction

Parameters

string|boolean $transactionMode Transaction mode, or false to ignore. Deprecated and will be removed in SS5.
string|boolean $sessionCharacteristics Session characteristics, or false to ignore. Deprecated and will be removed in SS5.

Return Value

bool True on success

Exceptions

DatabaseException on failure

at line 34
bool transactionEnd()

Complete a transaction

Return Value

bool True on success

Exceptions

DatabaseException on failure

at line 43
bool transactionRollback(string $savepoint = null)

Roll-back a transaction

Parameters

string $savepoint If set, roll-back to the named savepoint

Return Value

bool True on success

Exceptions

DatabaseException on failure

at line 51
transactionSavepoint(string $savepoint)

Create a new savepoint

Parameters

string $savepoint The savepoint name

Exceptions

DatabaseException on failure

at line 59
int transactionDepth()

Return the depth of the transaction For unnested transactions returns 1 while in a transaction, 0 otherwise

Return Value

int

at line 68
boolean supportsSavepoints()

Return true if savepoints are supported by this transaction manager.

Savepoints aren't supported by all database connectors (notably PDO doesn't support them) and should be used with caution.

Return Value

boolean