Class TActiveRecordStateRegistry

Description

Active record Unit of Work class and Identity Map.

Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems.

This registry keeps track of everything you do during a business transaction that can affect the database. When you're done, it figures out everything that needs to be done to alter the database as a result of your work.

The object can only be in one of the four states: "new", "clean", "dirty" or "removed". A "new" object is one that is created not by loading the record from database. A "clean" object is one that is created by loading the record from datase. A "dirty" object is one that is marked as dirty or a "clean" object that has its internal state altered (done by using == object comparision). A "removed" object is one that is marked for deletion.

See the "Active Record Object States.png" in the docs directory for state transition diagram.

  • since: 3.1
  • version: $Id: TActiveRecordStateRegistry.php 1899 2007-05-04 08:37:12Z wei $
  • author: Wei Zhuo <weizho[at]gmail[dot]com>

Located in /Data/ActiveRecord/TActiveRecordStateRegistry.php (line 38)


	
			
Method Summary
TActiveRecordStateRegistry __construct ()
void assertNotNull (mixed $obj)
boolean commit (TActiveRecord $record, TActiveRecordGateway $gateway)
string getObjectDataKey (mixed $data)
boolean isCleanObject (TActiveRecord $obj)
boolean isDirtyObject (TActiveRecord $obj)
boolean isNewObject (TActiveRecord $obj)
boolean isRemovedObject (TActiveRecord $obj)
void removeClean (TActiveRecord $obj)
void removeDirty (TActiveRecord $obj)
Methods
Constructor __construct (line 46)

Initialize the registry.

  • access: public
TActiveRecordStateRegistry __construct ()
assertNotNull (line 62)

Ensure that object is not null.

  • access: protected
void assertNotNull (mixed $obj)
commit (line 219)

Commit the object to database: * a new record is inserted if the object is new, object becomes clean.

* the record is updated if the object is dirty, object becomes clean. * the record is deleted if the object is marked for removal.

  • return: true if commit was successful, false otherwise.
  • access: public
boolean commit (TActiveRecord $record, TActiveRecordGateway $gateway)
getObjectDataKey (line 54)
  • return: hash of the data.
  • access: protected
string getObjectDataKey (mixed $data)
isCleanObject (line 168)

Test whether an object is in the clean state.

  • return: true if object is clean, false otherwise.
  • access: public
boolean isCleanObject (TActiveRecord $obj)
isDirtyObject (line 155)

Test whether an object is dirty or has been modified.

  • return: true if the object is dirty, false otherwise.
  • access: public
boolean isDirtyObject (TActiveRecord $obj)
isNewObject (line 181)

Test whether an object is a new instance.

  • return: true if object is newly created, false otherwise.
  • access: public
boolean isNewObject (TActiveRecord $obj)
isRemovedObject (line 204)

Test whether an object is marked for deletion.

  • return: true if object is marked for deletion, false otherwise.
  • access: public
boolean isRemovedObject (TActiveRecord $obj)
registerClean (line 97)

Register a clean object attached to a specific data that was used to populate the object. This acts as an object cache.

  • access: public
void registerClean (TActiveRecord $obj)
registerRemoved (line 74)

Register the object for deletion, when the object invokes its delete() method the corresponding row in the database is deleted.

  • access: public
  • throws: TActiveRecordException if object is null.
void registerRemoved (TActiveRecord $obj)
removeClean (line 121)

Remove object from clean state.

  • access: protected
void removeClean (TActiveRecord $obj)
removeCleanOrDirty (line 133)

Remove object from dirty and clean state.

  • access: protected
void removeCleanOrDirty (TActiveRecord $obj)
removeDirty (line 109)

Remove the object from dirty state.

  • access: protected
void removeDirty (TActiveRecord $obj)
removeRemovedObject (line 145)

Remove object from removed state.

  • access: protected
void removeRemovedObject (TActiveRecord $obj)
shouldPersistObject (line 194)
  • return: true if object is dirty or is new.
  • access: public
boolean shouldPersistObject (TActiveRecord $obj)

Documentation generated on Sun, 30 Sep 2007 19:10:33 -0400 by phpDocumentor 1.3.0RC4