Transaction Interface Reference

Detailed Description

Transaction implements the Unit of Work pattern as it defines the interface for maintaining a list of PersistentObject changes inside a business transaction and commit/rollback them.

Transaction also serves as an Identity Map for loaded objects.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 21 of file Transaction.php.

+ Inheritance diagram for Transaction:

Public Member Functions

 begin ()
 
 commit ()
 
 commitCollect ()
 
 rollback ()
 
 isActive ()
 
 attach (PersistentObject $object)
 
 detach (ObjectId $oid)
 
 getLoaded (ObjectId $oid)
 
 getObjects ()
 

Member Function Documentation

◆ begin()

begin ( )

Set the transaction active (object changes will be recorded).

Implemented in DefaultTransaction.

◆ commit()

commit ( )

Commit the object changes to the storage.

Sets the transaction to inactive.

Returns
Array of executed statements (see PersistenceMapper::getStatements())

Implemented in DefaultTransaction.

◆ commitCollect()

commitCollect ( )

Collect object change statements.

Acts like a normal commit, but does not execute the statements. Sets the transaction to inactive.

Returns
Array of statements to be executed (see PersistenceMapper::getStatements())

Implemented in DefaultTransaction.

◆ rollback()

rollback ( )

Discard the object changes.

Sets the transaction to inactive.

Implemented in DefaultTransaction.

◆ isActive()

isActive ( )

Check if the transaction is active.

Returns
Boolean

Implemented in DefaultTransaction.

◆ attach()

attach ( PersistentObject  $object)

Attach an object to the transaction.

The returned object is the attached instance.

Parameters
$objectThe object
Returns
PersistentObject

Implemented in DefaultTransaction.

◆ detach()

detach ( ObjectId  $oid)

Detach an object from the transaction.

All local changes will not be stored. Afterwards the object is unknown to the transaction.

Parameters
$oidThe object id of the object

Implemented in DefaultTransaction.

◆ getLoaded()

getLoaded ( ObjectId  $oid)

Get a loaded object.

Parameters
$oidObjectId of the object
Returns
PersistentObject instance or null if not loaded yet

Implemented in DefaultTransaction.

◆ getObjects()

getObjects ( )

Get all objects currently involved in the transaction.

Returns
Array of PersistentObject instances

Implemented in DefaultTransaction.