Classes:
Doctrine
Doctrine_Access
Doctrine_Adapter
Doctrine_Adapter_Db2_Exception
Doctrine_Adapter_Exception
Doctrine_Adapter_Statement
Doctrine_AuditLog
Doctrine_AuditLog_Listener
Doctrine_Collection
Doctrine_Collection_Exception
Doctrine_Collection_Iterator
Doctrine_Collection_Iterator_Expandable
Doctrine_Collection_Iterator_Normal
Doctrine_Collection_Iterator_Offset
Doctrine_Collection_Offset
Doctrine_Column
Doctrine_Compiler
Doctrine_Compiler_Exception
Doctrine_Configurable
Doctrine_Connection
Doctrine_Connection_Common
Doctrine_Connection_Db2
Doctrine_Connection_Exception
Doctrine_Connection_Firebird
Doctrine_Connection_Firebird_Exception
Doctrine_Connection_Informix
Doctrine_Connection_Informix_Exception
Doctrine_Connection_Mock
Doctrine_Connection_Module
Doctrine_Connection_Mssql
Doctrine_Connection_Mssql_Exception
Doctrine_Connection_Mysql
Doctrine_Connection_Mysql_Exception
Doctrine_Connection_Oracle
Doctrine_Connection_Oracle_Exception
Doctrine_Connection_Pgsql
Doctrine_Connection_Pgsql_Exception
Doctrine_Connection_Profiler
Doctrine_Connection_Profiler_Exception
Doctrine_Connection_Sqlite
Doctrine_Connection_Sqlite_Exception
Doctrine_Connection_Statement
Doctrine_Connection_UnitOfWork
Doctrine_DataDict
Doctrine_DataDict_Exception
Doctrine_DataDict_Informix
Doctrine_DataType
Doctrine_Db
Doctrine_Event
Doctrine_EventListener
Doctrine_EventListener_Chain
Doctrine_EventListener_Exception
Doctrine_Exception
Doctrine_Export
Doctrine_Export_Exception
Doctrine_Export_Firebird
Doctrine_Export_Frontbase
Doctrine_Export_Mssql
Doctrine_Export_Mysql
Doctrine_Export_Oracle
Doctrine_Export_Pgsql
Doctrine_Export_Reporter
Doctrine_Export_Schema
Doctrine_Export_Schema_Xml
Doctrine_Export_Schema_Yml
Doctrine_Export_Sqlite
Doctrine_Expression
Doctrine_Expression_Driver
Doctrine_Expression_Exception
Doctrine_Expression_Firebird
Doctrine_Expression_Informix
Doctrine_Expression_Mock
Doctrine_Expression_Mssql
Doctrine_Expression_Mysql
Doctrine_Expression_Oracle
Doctrine_Expression_Pgsql
Doctrine_Expression_Sqlite
Doctrine_File
Doctrine_File_Index
Doctrine_Formatter
Doctrine_Hook
Doctrine_Hook_Equal
Doctrine_Hook_Integer
Doctrine_Hook_Parser
Doctrine_Hook_Parser_Complex
Doctrine_Hook_WordLike
Doctrine_Hydrate
Doctrine_Hydrate_Array
Doctrine_Hydrate_Exception
Doctrine_Hydrate_Record
Doctrine_Import
Doctrine_Import_Builder
Doctrine_Import_Builder_BaseClass
Doctrine_Import_Builder_Exception
Doctrine_Import_Exception
Doctrine_Import_Firebird
Doctrine_Import_Informix
Doctrine_Import_Mssql
Doctrine_Import_Mysql
Doctrine_Import_Oracle
Doctrine_Import_Pgsql
Doctrine_Import_Reader
Doctrine_Import_Reader_Db
Doctrine_Import_Reader_Exception
Doctrine_Import_Reader_Xml_Propel
Doctrine_Import_Schema
Doctrine_Import_Schema_Xml
Doctrine_Import_Schema_Yml
Doctrine_Import_Sqlite
Doctrine_IntegrityMapper
Doctrine_Lib
Doctrine_Locking_Exception
Doctrine_Locking_Manager_Pessimistic
Doctrine_Manager
Doctrine_Manager_Exception
Doctrine_Node
Doctrine_Node_AdjacencyList
Doctrine_Node_AdjacencyList_LevelOrderIterator
Doctrine_Node_AdjacencyList_PostOrderIterator
Doctrine_Node_AdjacencyList_PreOrderIterator
Doctrine_Node_Exception
Doctrine_Node_MaterializedPath
Doctrine_Node_MaterializedPath_LevelOrderIterator
Doctrine_Node_MaterializedPath_PostOrderIterator
Doctrine_Node_MaterializedPath_PreOrderIterator
Doctrine_Node_NestedSet
Doctrine_Node_NestedSet_LevelOrderIterator
Doctrine_Node_NestedSet_PostOrderIterator
Doctrine_Node_NestedSet_PreOrderIterator
Doctrine_Null
Doctrine_Object
Doctrine_Plugin
Doctrine_Query
Doctrine_Query_Abstract
Doctrine_Query_Check
Doctrine_Query_Condition
Doctrine_Query_Exception
Doctrine_Query_Filter
Doctrine_Query_Filter_Chain
Doctrine_Query_From
Doctrine_Query_Groupby
Doctrine_Query_Having
Doctrine_Query_JoinCondition
Doctrine_Query_Limit
Doctrine_Query_Offset
Doctrine_Query_Orderby
Doctrine_Query_Parser
Doctrine_Query_Part
Doctrine_Query_Select
Doctrine_Query_Set
Doctrine_Query_Where
Doctrine_RawSql
Doctrine_RawSql_Exception
Doctrine_Record
Doctrine_Record_Abstract
Doctrine_Record_Exception
Doctrine_Record_Filter
Doctrine_Record_Iterator
Doctrine_Record_Listener
Doctrine_Record_Listener_Chain
Doctrine_Record_State_Exception
Doctrine_Relation
Doctrine_Relation_Association
Doctrine_Relation_Association_Self
Doctrine_Relation_Exception
Doctrine_Relation_ForeignKey
Doctrine_Relation_LocalKey
Doctrine_Relation_Nest
Doctrine_Relation_Parser
Doctrine_Relation_Parser_Exception
Doctrine_Schema
Doctrine_Schema_Column
Doctrine_Schema_Database
Doctrine_Schema_Exception
Doctrine_Schema_Object
Doctrine_Schema_Relation
Doctrine_Schema_Table
Doctrine_Search
Doctrine_Search_Analyzer
Doctrine_Search_Analyzer_Exception
Doctrine_Search_Analyzer_Standard
Doctrine_Search_Exception
Doctrine_Search_Indexer
Doctrine_Search_Indexer_Dir
Doctrine_Search_Indexer_Exception
Doctrine_Search_Listener
Doctrine_Search_Parser
Doctrine_Search_Query
Doctrine_Search_Record
Doctrine_Search_Scorer
Doctrine_Search_Template
Doctrine_Sequence
Doctrine_Sequence_Db2
Doctrine_Sequence_Exception
Doctrine_Sequence_Firebird
Doctrine_Sequence_Informix
Doctrine_Sequence_Mssql
Doctrine_Sequence_Mysql
Doctrine_Sequence_Oracle
Doctrine_Sequence_Pgsql
Doctrine_Sequence_Sqlite
Doctrine_Table
Doctrine_Table_Exception
Doctrine_Table_Repository
Doctrine_Table_Repository_Exception
Doctrine_Template
Doctrine_Template_NestedSet
Doctrine_Template_Searchable
Doctrine_Template_Taggable
Doctrine_Template_Versionable
Doctrine_Tokenizer
Doctrine_Transaction
Doctrine_Transaction_Exception
Doctrine_Transaction_Firebird
Doctrine_Transaction_Informix
Doctrine_Transaction_Mock
Doctrine_Transaction_Mssql
Doctrine_Transaction_Mysql
Doctrine_Transaction_Oracle
Doctrine_Transaction_Pgsql
Doctrine_Transaction_Sqlite
Doctrine_Tree
Doctrine_Tree_AdjacencyList
Doctrine_Tree_Exception
Doctrine_Tree_MaterializedPath
Doctrine_Tree_NestedSet
Doctrine_Util
Doctrine_Validator
Doctrine_Validator_Country
Doctrine_Validator_Creditcard
Doctrine_Validator_Date
Doctrine_Validator_Email
Doctrine_Validator_Enum
Doctrine_Validator_ErrorStack
Doctrine_Validator_Exception
Doctrine_Validator_HtmlColor
Doctrine_Validator_Ip
Doctrine_Validator_Minlength
Doctrine_Validator_Nospace
Doctrine_Validator_Notblank
Doctrine_Validator_Notnull
Doctrine_Validator_Range
Doctrine_Validator_Regexp
Doctrine_Validator_Unique
Doctrine_Validator_Unsigned
Doctrine_Validator_Usstate
Doctrine_View
Doctrine_View_Exception
Doctrine_Cache
Doctrine_Cache
Doctrine_Cache_Apc
Doctrine_Cache_Array
Doctrine_Cache_Db
Doctrine_Cache_Driver
Doctrine_Cache_Exception
Doctrine_Cache_Memcache
Doctrine_Adapter
Doctrine_Adapter_Db2
Doctrine_Adapter_Mock
Doctrine_Adapter_Mysqli
Doctrine_Adapter_Oracle
Doctrine_Adapter_Statement_Mock
Doctrine_DataDict
Doctrine_DataDict_Firebird
Doctrine_DataDict_Mssql
Doctrine_DataDict_Mysql
Doctrine_DataDict_Oracle
Doctrine_DataDict_Pgsql
Doctrine_DataDict_Sqlite

# Class: Doctrine_Transaction

Source Location: /Doctrine/Transaction.php

## Class Doctrine_Transaction

Class Overview

Doctrine_Transaction Handles transaction savepoint and isolation abstraction Located in /Doctrine/Transaction.php [line 35]
    Doctrine_Connection_Module
       |
       --Doctrine_Transaction
Author(s): Konsta Vesterinen <kvesteri@cc.hut.fi> Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library) Information Tags:
Version: | $Revision: 2268 $
Link: | www.phpdoctrine.com
Since: | 1.0
License: | LGPL
| Properties $delete $invalid $savePoints $transactionLevel $_collections | Methods addCollection addDelete addInvalid beginTransaction bulkDelete commit createSavePoint getDeletes getIsolation getState getTransactionLevel releaseSavePoint removeSavePoints rollback rollbackSavePoint setIsolation setTransactionLevel

[ Top ]
Direct descendents

Child Class | Description
--- | ---
Doctrine_Transaction_Firebird |
Doctrine_Transaction_Informix |
Doctrine_Transaction_Mock | Doctrine_Transaction_Mock This class is used for testing purposes
Doctrine_Transaction_Mssql |
Doctrine_Transaction_Mysql |
Doctrine_Transaction_Oracle |
Doctrine_Transaction_Pgsql |
Doctrine_Transaction_Sqlite |

[ Top ]
Inherited Properties, Constants, and Methods

Inherited Properties | Inherited Methods | Inherited Constants
--- | --- | ---
Inherited From Doctrine_Connection_Module Doctrine_Connection_Module::$conn Doctrine_Connection_Module::$moduleName | Inherited From Doctrine_Connection_Module Doctrine_Connection_Module::__construct() Doctrine_Connection_Module::getConnection() getConnection returns the connection object this module uses Doctrine_Connection_Module::getModuleName() getModuleName returns the name of this module |

[ Top ]
Constant Summary

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
STATE_SLEEP | Doctrine_Transaction is in sleep state when it has no active transactions

[ Top ]
Property Summary

array | $delete |
array | $invalid |
array | $savePoints |
integer | $transactionLevel |
array | $_collections |

[ Top ]
Method Summary

Doctrine_Transaction | addCollection() | addCollection adds a collection in the internal array of collections
void | addDelete() | addDelete adds record into pending delete list
boolean | addInvalid() | addInvalid adds record into invalid records list
integer | beginTransaction() | beginTransaction Start a transaction or set a savepoint.
void | bulkDelete() | bulkDelete deletes all records from the pending delete list
boolean | commit() | commit 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.
void | createSavePoint() | releaseSavePoint creates a new savepoint
array | getDeletes() | returns the pending delete list
string | getIsolation() | getTransactionIsolation
integer | getState() | getState returns the state of this connection
integer | getTransactionLevel() | getTransactionLevel get the current transaction nesting level
void | releaseSavePoint() | releaseSavePoint releases given savepoint
integer | removeSavePoints() | removeSavePoints removes a savepoint from the internal savePoints array of this transaction object and all its children savepoints
boolean | rollback() | rollback
void | rollbackSavePoint() | rollbackSavePoint releases given savepoint
void | setIsolation() | setIsolation
Doctrine_Transaction | setTransactionLevel() | getTransactionLevel set the current transaction nesting level

[ Top ]
Properties
array $delete = array() [line 61]
API Tags:

Access: | protected

[ Top ]
array $invalid = array() [line 56]
API Tags:

Access: | protected

[ Top ]
array $savePoints = array() [line 65]
API Tags:

Access: | protected

[ Top ]
integer $transactionLevel = 0 [line 52]
API Tags:

Access: | protected

[ Top ]
array $_collections = array() [line 69]
API Tags:

Access: | protected

[ Top ]
Methods
addCollection [line 82]

`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

API Tags:

Return: | this object
Access: | public

[ Top ]
addDelete [line 116]

`void addDelete( Doctrine_Record $record )`

addDelete adds record into pending delete list

Parameters:

Doctrine_Record | $record: | a record to be added

API Tags:

Access: | public

[ Top ]
addInvalid [line 130]

`boolean addInvalid( Doctrine_Record $record )`

addInvalid adds record into invalid records list

Parameters:

Doctrine_Record | $record: |

API Tags:

Return: | false if record already existed in invalid records list, otherwise true
Access: | public

[ Top ]
beginTransaction [line 238]

`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

Listeners: onPreTransactionBegin, onTransactionBegin

Parameters:

string | $savepoint: | name of a savepoint to set

API Tags:

Return: | current transaction nesting level
Access: | public

Information Tags:

Throws: | Doctrine_Transaction_Exception if the transaction fails at database level

[ Top ]
bulkDelete [line 155]

`void bulkDelete( )`

bulkDelete deletes all records from the pending delete list

API Tags:

Access: | public

[ Top ]
commit [line 290]

`boolean commit( [string $savepoint = null] )`

commit 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

API Tags:

Return: | false if commit couldn't be performed, true otherwise
Access: | public

Information Tags:

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

[ Top ]
createSavePoint [line 421]

`void createSavePoint( string $savepoint )`

releaseSavePoint creates a new savepoint

Parameters:

string | $savepoint: | name of a savepoint to create

API Tags:

Access: | protected

Redefined in descendants as:

- Doctrine_Transaction_Firebird::createSavePoint() : createSavepoint creates a new savepoint
- Doctrine_Transaction_Mysql::createSavePoint() : createSavepoint creates a new savepoint
- Doctrine_Transaction_Oracle::createSavePoint() : createSavepoint creates a new savepoint
- Doctrine_Transaction_Pgsql::createSavePoint() : createSavepoint creates a new savepoint

[ Top ]
getDeletes [line 144]

`array getDeletes( )`

returns the pending delete list

API Tags:

Access: | public

[ Top ]
getIsolation [line 519]

`string getIsolation( )`

getTransactionIsolation

fetches the current session transaction isolation level

note: some drivers may support setting the transaction isolation level but not fetching it

API Tags:

Return: | returns the current session transaction isolation level
Access: | public

Information Tags:

Throws: | PDOException if something fails at the PDO level
Throws: | Doctrine_Transaction_Exception if the feature is not supported by the driver

Redefined in descendants as:

- Doctrine_Transaction_Mysql::getIsolation() : getTransactionIsolation

[ Top ]
getState [line 95]

`integer getState( )`

getState returns the state of this connection

API Tags:

Return: | the connection state
See: | Doctrine_Connection_Transaction::STATE_* constants
Access: | public

[ Top ]
getTransactionLevel [line 209]

`integer getTransactionLevel( )`

getTransactionLevel get the current transaction nesting level

API Tags:

Access: | public

[ Top ]
releaseSavePoint [line 433]

`void releaseSavePoint( string $savepoint )`

releaseSavePoint releases given savepoint

Parameters:

string | $savepoint: | name of a savepoint to release

API Tags:

Access: | protected

Redefined in descendants as:

- Doctrine_Transaction_Firebird::releaseSavePoint() : releaseSavePoint releases given savepoint
- Doctrine_Transaction_Mysql::releaseSavePoint() : releaseSavePoint releases given savepoint
- Doctrine_Transaction_Oracle::releaseSavePoint() : releaseSavePoint releases given savepoint
- Doctrine_Transaction_Pgsql::releaseSavePoint() : releaseSavePoint releases given savepoint

[ Top ]
removeSavePoints [line 458]

`integer removeSavePoints( sring $savepoint )`

removeSavePoints removes a savepoint from the internal savePoints array of this transaction object and all its children savepoints

Parameters:

sring | $savepoint: | name of the savepoint to remove

API Tags:

Return: | removed savepoints
Access: | private

[ Top ]
rollback [line 370]

`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

API Tags:

Return: | false if rollback couldn't be performed, true otherwise
Access: | public

Information Tags:

Throws: | Doctrine_Transaction_Exception if the rollback operation fails at database level

[ Top ]
rollbackSavePoint [line 445]

`void rollbackSavePoint( string $savepoint )`

rollbackSavePoint releases given savepoint

Parameters:

string | $savepoint: | name of a savepoint to rollback to

API Tags:

Access: | protected

Redefined in descendants as:

- Doctrine_Transaction_Firebird::rollbackSavePoint() : rollbackSavePoint releases given savepoint
- Doctrine_Transaction_Mysql::rollbackSavePoint() : rollbackSavePoint releases given savepoint
- Doctrine_Transaction_Oracle::rollbackSavePoint() : rollbackSavePoint releases given savepoint
- Doctrine_Transaction_Pgsql::rollbackSavePoint() : rollbackSavePoint releases given savepoint

[ Top ]
setIsolation [line 502]

`void setIsolation( string $isolation )`

setIsolation

Set the transacton isolation level. (implemented by the connection drivers)

example:

1. $tx->setIsolation('READ UNCOMMITTED');

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)

API Tags:

Access: | public

Information Tags:

Throws: | PDOException if something fails at the PDO level
Throws: | Doctrine_Transaction_Exception if the feature is not supported by the driver

Redefined in descendants as:

- Doctrine_Transaction_Firebird::setIsolation() : Set the transacton isolation level.
- Doctrine_Transaction_Mssql::setIsolation() : Set the transacton isolation level.
- Doctrine_Transaction_Mysql::setIsolation() : Set the transacton isolation level.
- Doctrine_Transaction_Oracle::setIsolation() : Set the transacton isolation level.
- Doctrine_Transaction_Pgsql::setIsolation() : Set the transacton isolation level.
- Doctrine_Transaction_Sqlite::setIsolation() : Set the transacton isolation level.

[ Top ]
setTransactionLevel [line 219]

`Doctrine_Transaction setTransactionLevel( $level )`

getTransactionLevel set the current transaction nesting level

Parameters:

| $level: |

API Tags:

Return: | this object
Access: | public

[ Top ]
Constants
STATE_ACTIVE = 1 [line 44]

Doctrine_Transaction is in active state when it has one active transaction

[ Top ]
STATE_BUSY = 2 [line 48]

Doctrine_Transaction is in busy state when it has multiple active transactions

[ Top ]
STATE_SLEEP = 0 [line 40]

Doctrine_Transaction is in sleep state when it has no active transactions

[ Top ]