Path

ez components / documentation / api reference / 2008.1 / persistentobject


PersistentObject: ezcPersistentSequenceGenerator

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcPersistentSequenceGenerator

Generates IDs based on the PDO::lastInsertId method. [source]
It is recommended to use auto_increment id columns for databases supporting it. This includes MySQL and SQLite. Use ezcPersistentNativeGenerator for those!
For none auto_increment databases:
1.  CREATE TABLE test id integer unsigned not nullPRIMARY KEY (id ));
2.  CREATE SEQUENCE test_seq START 1;
This class reads the parameters:
  • sequence - The name of the database sequence keeping track of the ID. This field should be ommited for databases supporting auto_increment.

Parents

ezcPersistentIdentifierGenerator
   |
   --ezcPersistentSequenceGenerator

Method Summary

public int postSave( $def, $db )
Returns the integer value of the generated identifier for the new object.
public void preSave( $def, $db, $q )
Fetches the next sequence value for PostgreSQL and Oracle implementations.

Inherited Methods

From ezcPersistentIdentifierGenerator :
public bool ezcPersistentIdentifierGenerator::checkPersistence()
Returns true if the object is persistent already.
public abstract int ezcPersistentIdentifierGenerator::postSave()
Returns the value of the generated identifier for the new object.
public abstract void ezcPersistentIdentifierGenerator::preSave()
Called prior to executing the insert query that saves the data to the database.

Methods

postSave

int postSave( ezcPersistentObjectDefinition $def, $db )
Returns the integer value of the generated identifier for the new object.
Called right after execution of the insert query. Dispatches to ezcPersistentNativeGenerator for MySQL.

Parameters

Name Type Description
$def ezcPersistentObjectDefinition  
$db ezcDbHandler  

Redefinition of

Method Description
ezcPersistentIdentifierGenerator::postSave() Returns the value of the generated identifier for the new object.

preSave

void preSave( ezcPersistentObjectDefinition $def, $db, $q )
Fetches the next sequence value for PostgreSQL and Oracle implementations.
Fetches the next sequence value for PostgreSQL and Oracle implementations. Dispatches to ezcPersistentNativeGenerator for MySQL.

Parameters

Name Type Description
$def ezcPersistentObjectDefinition  
$db ezcDbHandler  
$q ezcQueryInsert  

Redefinition of

Method Description
ezcPersistentIdentifierGenerator::preSave() Called prior to executing the insert query that saves the data to the database.

Last updated: Wed, 18 Jun 2008