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): Information Tags:
Version:  $Revision: 2268 $
Link:  www.phpdoctrine.com
Since:  1.0
License:  LGPL

Properties

Methods

[ Top ]
Direct descendents
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:

[ 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:

[ 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:

[ 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:

[ 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:

[ 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 ]