Back

Editing, Updating and Creating Records
eventPostInsertSQL
Name of function to call after New Record is created The function is passed 3 parameters. The first parameter is $key, the primary key. The second is $insertok which is set to true if the record was inserted correctly. The 3rd parameter is the $lens object. Note that some PHP extensions do not support the insert_id() function such as Oracle/OCI8 and Interbase (we set $key to the OID in PostgreSQL). For those databases, the $key variable will be empty. If you are using sequences to set the default value of the primary key, then you can still obtain the current value of the sequence. For example if you are using oci8 and $seqname holds the name of your sequence: `$rs = $lens->connection->Execute("SELECT $seqname.currval FROM dual"); $key = $rs->fields[0];` Syntax `function preinsert($lens) { GLOBAL $HTTP_POST_VARS; $lens->connection->BeginTrans(); } function postinsert($key, $insertok, $lens) { if ($insertok) { $rs = $lens->Execute("insert into childtable (parent) values ($key)"); if ($rs) $lens->connection->CommitTrans(); else $insertok = false; } if (!$insertok) { $lens->connection->RollbackTrans(); } } $lens->eventPreInsertSQL = 'preinsert'; $lens->eventPostInsertSQL = 'postinsert';` Basic:No Advanced/Enterprise:Yes DynamicEdit:No [Version 1.0]