Back
keyVariable
Editing, Updating and Creating Records
keyVariable
Sets a PHP global variable to the primary key of the currently selected record
Default:
Typically you will store the current record's primary key in a session variable in this way:

global $DB;
if (empty($_SESSION['ID])) $_SESSION['ID'] = false;
$ID =& $_SESSION['ID'];

# and in your applet code, set:
$lens->keyVariable = 'ID';

Managing ID's for New Records



Tracking keyVariable is a problem when we create a new records. We need a mechanism to update $ID after the record is created. In the above example, $ID is updated with the created record's serial id, if the database supports serial id's (mssql, mysql).

If the database does not support serial id's, then we provide a second parameter to keyVariable where you can define some sql to execute to obtain the primary key of the newly inserted record. In this example, we store the serial id in an oracle sequence:

$lens->keyVariable = "ID/select sequence1 from dual";

In the above example, you will still need to define an oracle trigger which sets 'table_id' to sequence1.nextval. Also note the seperator used is the option seperator (/) and not the field seperator (^).

Note that if $ID is already defined, then instead of showing the New Record form, we will be viewing or editing the record specified by $ID.

Limitations: Only works with numeric/integer primary keys currently.

Row Selection and Highlighting
When this property is set, row highlighting and selection using javascript is enabled (since 3.5)

 Basic:Yes  Advanced/Enterprise:Yes  DynamicEdit:Yes   [Version 3.1]