* CREATE TABLE test * ( id integer unsigned not null auto_increment, PRIMARY KEY (id )); * * * @package PersistentObject * @version 1.7rc1 */ class ezcPersistentNativeGenerator extends ezcPersistentIdentifierGenerator { /** * No functionality, since database handles ID generation automatically. * * @param ezcPersistentObjectDefinition $def * @param ezcDbHandler $db * @param ezcQueryInsert $q * @return void */ public function preSave( ezcPersistentObjectDefinition $def, ezcDbHandler $db, ezcQueryInsert $q ) { } /** * Returns the integer value of the generated identifier for the new object. * Called right after execution of the insert query. * * @param ezcPersistentObjectDefinition $def * @param ezcDbHandler $db * @return int */ public function postSave( ezcPersistentObjectDefinition $def, ezcDbHandler $db ) { $id = (int)$db->lastInsertId(); // check that the value was in fact successfully received. if ( $db->errorCode() != 0 ) { return null; } return $id; } } ?>