Apache Zeta Components Manual :: Docs For Class ezcPersistentIdentifierGenerator
PersistentObject::ezcPersistentIdentifierGenerator
Class ezcPersistentIdentifierGenerator
The interface between the class that generates unique identifiers when creating new objects and the session.
Implement this interface if you want a new strategy for generating unique identifier. This interface is not intended to be exposed to the application.
Implementations should accept any parameters through a associative array in the constructor:
- public function __construct( array $params );
The structure of the parameters is array( 'parameter_name' => 'parameter_value' ).
Source for this file: /PersistentObject/src/interfaces/identifier_generator.php
Version: | //autogen// |
Descendants
Child Class | Description |
---|---|
ezcPersistentSequenceGenerator | Generates IDs based on the PDO::lastInsertId method. |
ezcPersistentManualGenerator | This identifier generator does not generate any ID's. Instead the user must manually assign an ID when the object is saved. |
ezcPersistentNativeGenerator | Generates IDs based on the PDO::lastInsertId method. |
Method Summary
public bool |
checkPersistence(
$def
, $db
, $state
)
Returns true if the object is persistent already. |
public abstract int |
postSave(
$def
, $db
)
Returns the value of the generated identifier for the new object. |
public abstract void |
preSave(
$def
, $db
, $q
)
Called prior to executing the insert query that saves the data to the database. |
Methods
checkPersistence
Returns true if the object is persistent already.
Called in the beginning of the save and update methods.
Persistent objects that are being saved must not exist in the database already.
The default implementation checks if the id is null. This is suitable for all implementations where the id is generated by the database or by the implementation of preSave().
Parameters:
Name | Type | Description |
---|---|---|
$def |
ezcPersistentObjectDefinition | |
$db |
ezcDbHandler | |
$state |
array(key=>value) |
Redefined in descendants as:
Method | Description |
---|---|
ezcPersistentManualGenerator::checkPersistence() |
Returns true if the object is persistent already. |
postSave
Returns the value of the generated identifier for the new object.
Called right after execution of the insert query. Returns null if it was not possible to generate a new ID.
Parameters:
Name | Type | Description |
---|---|---|
$def |
ezcPersistentObjectDefinition | |
$db |
ezcDbHandler |
Redefined in descendants as:
Method | Description |
---|---|
ezcPersistentSequenceGenerator::postSave() |
Returns the integer value of the generated identifier for the new object. |
ezcPersistentManualGenerator::postSave() |
Returns the value of the generated identifier for the new object. |
ezcPersistentNativeGenerator::postSave() |
Returns the integer value of the generated identifier for the new object. |
preSave
Called prior to executing the insert query that saves the data to the database.
All the data has been set on the query prior to calling this method.
Parameters:
Name | Type | Description |
---|---|---|
$def |
ezcPersistentObjectDefinition | |
$db |
ezcDbHandler | |
$q |
ezcQueryInsert |
Redefined in descendants as:
Method | Description |
---|---|
ezcPersistentSequenceGenerator::preSave() |
Fetches the next sequence value for PostgreSQL and Oracle implementations. |
ezcPersistentManualGenerator::preSave() |
Sets the correct id on the insert query. |
ezcPersistentNativeGenerator::preSave() |
No functionality, since database handles ID generation automatically. |