Makes phpLens autogenerate an integer to be stored into keyCol when inserting a new record Default: Set this property to true to enable generation of keys by phpLens. If you want to use a custom generator, set this property to the name of the PHP function that returns the key. The generated key is also passed to the eventPostInsertSQL property, and also stored in the generatedKey property after Render() is called.
Note that is only required on selected databases which do not have an auto-incement primary key, including early-PostgreSQL versions, Interbase and Oracle (oci8) currently. Internally, phpLens will create sequences or tables to manage the integer generation.
If you are using autoincrement columns generated by the database (eg. mysql or mssql), you can get the last inserted value using $lens->connection->Insert_ID();Syntax
# 1. generate integer key
$lens->autoGeneratedKey = true;
$lens->Render();
# 2. use a random function to generate the key.
function genrand()
{
return rand();
}
$lens->autoGenerateKey = 'genrand';
$lens->Render();
# now the generatedKey value is available after an insert
$id = $lens->generatedKey; Basic:Yes Advanced/Enterprise:Yes DynamicEdit:Yes [Version 1.3]
|