class Doctrine_Transaction_Mysql extends Doctrine_Transaction (View source)

Constants

STATE_SLEEP

Doctrine_Transaction is in sleep state when it has no active transactions

STATE_ACTIVE

Doctrine_Transaction is in active state when it has one active transaction

STATE_BUSY

Doctrine_Transaction is in busy state when it has multiple active transactions

Properties

protected Doctrine_Connection $conn from Doctrine_Connection_Module
protected string $moduleName from Doctrine_Connection_Module
protected integer $_nestingLevel from Doctrine_Transaction
protected integer $_internalNestingLevel from Doctrine_Transaction
protected array $invalid from Doctrine_Transaction
protected array $savePoints from Doctrine_Transaction
protected array $_collections from Doctrine_Transaction

Methods

__construct(Doctrine_Connection $conn = null)

No description

getConnection()

getConnection returns the connection object this module uses

string
getModuleName()

getModuleName returns the name of this module

addCollection(Doctrine_Collection $coll)

addCollection adds a collection in the internal array of collections

integer
getState()

getState returns the state of this transaction module.

boolean
addInvalid(Doctrine_Record $record)

addInvalid adds record into invalid records list

array
getInvalid()

Return the invalid records

integer
getTransactionLevel()

getTransactionLevel get the current transaction nesting level

integer
beginTransaction(string $savepoint = null)

beginTransaction Start a transaction or set a savepoint.

boolean
commit(string $savepoint = null)

Commit the database changes done during a transaction that is in progress or release a savepoint. This function may only be called when auto-committing is disabled, otherwise it will fail.

boolean
rollback(string $savepoint = null)

rollback Cancel any database changes done during a transaction or since a specific savepoint that is in progress. This function may only be called when auto-committing is disabled, otherwise it will fail. Therefore, a new transaction is implicitly started after canceling the pending changes.

void
createSavePoint(string $savepoint)

createSavepoint creates a new savepoint

void
releaseSavePoint(string $savepoint)

releaseSavePoint releases given savepoint

void
rollbackSavePoint(string $savepoint)

rollbackSavePoint releases given savepoint

_doRollback()

Performs the rollback.

_doCommit()

Performs the commit.

_doBeginTransaction()

Begins a database transaction.

void
setIsolation(string $isolation)

Set the transacton isolation level.

string
getIsolation()

getTransactionIsolation

beginInternalTransaction($savepoint = null)

Initiates a transaction.

Details

__construct(Doctrine_Connection $conn = null)

Parameters

Doctrine_Connection $conn Doctrine_Connection object, every connection module holds an instance of Doctrine_Connection

Doctrine_Connection getConnection()

getConnection returns the connection object this module uses

Return Value

Doctrine_Connection

string getModuleName()

getModuleName returns the name of this module

Return Value

string the name of this module

Doctrine_Transaction addCollection(Doctrine_Collection $coll)

addCollection adds a collection in the internal array of collections

at the end of each commit this array is looped over and of every collection Doctrine then takes a snapshot in order to keep the collections up to date with the database

Parameters

Doctrine_Collection $coll a collection to be added

Return Value

Doctrine_Transaction this object

integer getState()

getState returns the state of this transaction module.

Return Value

integer the connection state

See also

Doctrine_Connection_Transaction::STATE_* constants

boolean addInvalid(Doctrine_Record $record)

addInvalid adds record into invalid records list

Parameters

Doctrine_Record $record

Return Value

boolean false if record already existed in invalid records list, otherwise true

array getInvalid()

Return the invalid records

Return Value

array An array of invalid records

integer getTransactionLevel()

getTransactionLevel get the current transaction nesting level

Return Value

integer

getInternalTransactionLevel()

integer beginTransaction(string $savepoint = null)

beginTransaction Start a transaction or set a savepoint.

if trying to set a savepoint and there is no active transaction a new transaction is being started

This method should only be used by userland-code to initiate transactions. To initiate a transaction from inside Doctrine use {@link beginInternalTransaction()}.

Listeners: onPreTransactionBegin, onTransactionBegin

Parameters

string $savepoint name of a savepoint to set

Return Value

integer current transaction nesting level

Exceptions

Doctrine_Transaction_Exception if the transaction fails at database level

boolean commit(string $savepoint = null)

Commit the database changes done during a transaction that is in progress or release a savepoint. This function may only be called when auto-committing is disabled, otherwise it will fail.

Listeners: preTransactionCommit, postTransactionCommit

Parameters

string $savepoint name of a savepoint to release

Return Value

boolean false if commit couldn't be performed, true otherwise

Exceptions

Doctrine_Transaction_Exception if the transaction fails at database level
Doctrine_Validator_Exception if the transaction fails due to record validations

boolean rollback(string $savepoint = null)

rollback Cancel any database changes done during a transaction or since a specific savepoint that is in progress. This function may only be called when auto-committing is disabled, otherwise it will fail. Therefore, a new transaction is implicitly started after canceling the pending changes.

this method can be listened with onPreTransactionRollback and onTransactionRollback eventlistener methods

Parameters

string $savepoint name of a savepoint to rollback to

Return Value

boolean false if rollback couldn't be performed, true otherwise

Exceptions

Doctrine_Transaction_Exception if the rollback operation fails at database level

protected void createSavePoint(string $savepoint)

createSavepoint creates a new savepoint

Parameters

string $savepoint name of a savepoint to create

Return Value

void

protected void releaseSavePoint(string $savepoint)

releaseSavePoint releases given savepoint

Parameters

string $savepoint name of a savepoint to release

Return Value

void

protected void rollbackSavePoint(string $savepoint)

rollbackSavePoint releases given savepoint

Parameters

string $savepoint name of a savepoint to rollback to

Return Value

void

protected _doRollback()

Performs the rollback.

protected _doCommit()

Performs the commit.

protected _doBeginTransaction()

Begins a database transaction.

void setIsolation(string $isolation)

Set the transacton isolation level.

Parameters

string $isolation standard isolation level READ UNCOMMITTED (allows dirty reads) READ COMMITTED (prevents dirty reads) REPEATABLE READ (prevents nonrepeatable reads) SERIALIZABLE (prevents phantom reads)

Return Value

void

Exceptions

Doctrine_Transaction_Exception if using unknown isolation level
PDOException if something fails at the PDO level

string getIsolation()

getTransactionIsolation

Return Value

string returns the current session transaction isolation level

beginInternalTransaction($savepoint = null)

Initiates a transaction.

This method must only be used by Doctrine itself to initiate transactions. Userland-code must use {@link beginTransaction()}.

Parameters

$savepoint