class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module (View source)

Doctrine_Connection_UnitOfWork

Note: This class does not have the semantics of a real "Unit of Work" in 0.10/1.0. Database operations are not queued. All changes to objects are immediately written to the database. You can think of it as a unit of work in auto-flush mode.

Referential integrity is currently not always ensured.

Properties

protected Doctrine_Connection $conn from Doctrine_Connection_Module
protected string $moduleName from Doctrine_Connection_Module

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

void
saveGraph(Doctrine_Record $record, $replace = false)

Saves the given record and all associated records.

boolean
delete(Doctrine_Record $record)

Deletes the given record and all the related records that participate in an application-level delete cascade.

void
_cascadeDelete(Doctrine_Record $record, array $deletions)

Cascades an ongoing delete operation to related objects. Applies only on relations that have 'delete' in their cascade options.

saveRelatedForeignKeys(Doctrine_Record $record)

saveRelatedForeignKeys saves all related (through ForeignKey) records to $record

saveRelatedLocalKeys(Doctrine_Record $record)

saveRelatedLocalKeys saves all related (through LocalKey) records to $record

void
saveAssociations(Doctrine_Record $record)

saveAssociations

void
saveAll()

saveAll persists all the pending records from all tables

boolean
update(Doctrine_Record $record)

updates given record

boolean
insert(Doctrine_Record $record)

Inserts a record into database.

boolean
replace(Doctrine_Record $record)

Replaces a record into database.

void
processSingleInsert(Doctrine_Record $record)

Inserts a transient record in its table.

array
buildFlushTree(array $tables)

buildFlushTree builds a flush tree that is used in transactions

_assignSequence(Doctrine_Record $record, $fields = null)

No description

_assignIdentifier(Doctrine_Record $record)

No description

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

void saveGraph(Doctrine_Record $record, $replace = false)

Saves the given record and all associated records.

(The save() operation is always cascaded in 0.10/1.0).

Parameters

Doctrine_Record $record
$replace

Return Value

void

boolean delete(Doctrine_Record $record)

Deletes the given record and all the related records that participate in an application-level delete cascade.

this event can be listened by the onPreDelete and onDelete listeners

Parameters

Doctrine_Record $record

Return Value

boolean true on success, false on failure

protected void _cascadeDelete(Doctrine_Record $record, array $deletions)

Cascades an ongoing delete operation to related objects. Applies only on relations that have 'delete' in their cascade options.

This is an application-level cascade. Related objects that participate in the cascade and are not yet loaded are fetched from the database. Exception: many-valued relations are always (re-)fetched from the database to make sure we have all of them.

Parameters

Doctrine_Record $record
array $deletions

Return Value

void

Exceptions

PDOException If something went wrong at database level

saveRelatedForeignKeys(Doctrine_Record $record)

saveRelatedForeignKeys saves all related (through ForeignKey) records to $record

Parameters

Doctrine_Record $record

Exceptions

PDOException if something went wrong at database level

saveRelatedLocalKeys(Doctrine_Record $record)

saveRelatedLocalKeys saves all related (through LocalKey) records to $record

Parameters

Doctrine_Record $record

Exceptions

PDOException if something went wrong at database level

void saveAssociations(Doctrine_Record $record)

saveAssociations

this method takes a diff of one-to-many / many-to-many original and current collections and applies the changes

for example if original many-to-many related collection has records with primary keys 1,2 and 3 and the new collection has records with primary keys 3, 4 and 5, this method would first destroy the associations to 1 and 2 and then save new associations to 4 and 5

Parameters

Doctrine_Record $record

Return Value

void

Exceptions

Doctrine_Connection_Exception if something went wrong at database level

void saveAll()

saveAll persists all the pending records from all tables

Return Value

void

Exceptions

PDOException if something went wrong at database level

boolean update(Doctrine_Record $record)

updates given record

Parameters

Doctrine_Record $record record to be updated

Return Value

boolean whether or not the update was successful

boolean insert(Doctrine_Record $record)

Inserts a record into database.

This method inserts a transient record in the database, and adds it to the identity map of its correspondent table. It proxies to @see processSingleInsert(), trigger insert hooks and validation of data if required.

Parameters

Doctrine_Record $record

Return Value

boolean false if record is not valid

boolean replace(Doctrine_Record $record)

Replaces a record into database.

Parameters

Doctrine_Record $record

Return Value

boolean false if record is not valid

void processSingleInsert(Doctrine_Record $record)

Inserts a transient record in its table.

This method inserts the data of a single record in its assigned table, assigning to it the autoincrement primary key (if any is defined).

Parameters

Doctrine_Record $record

Return Value

void

array buildFlushTree(array $tables)

buildFlushTree builds a flush tree that is used in transactions

The returned array has all the initialized components in 'correct' order. Basically this means that the records of those components can be saved safely in the order specified by the returned array.

Parameters

array $tables an array of Doctrine_Table objects or component names

Return Value

array an array of component names in flushing order

protected _assignSequence(Doctrine_Record $record, $fields = null)

Parameters

Doctrine_Record $record
$fields

protected _assignIdentifier(Doctrine_Record $record)

Parameters

Doctrine_Record $record