Set this property to the global variable holding the USER ID for locking Default: To enable locking, set this property to the global variable to the user id of the person who is currently logged in. Then phpLens will keep track of the current user modifying the record, and prevent another user from editing the record. The variable data should be no more than 56 bytes long.
Supposed the userid is stored in $USERID, then set
$lens->lockRec = 'USERID';
PhpLens will transparently create the following table for storing lock records:
For MySQL and PostgreSQL:
CREATE TABLE phplens_lock (
LOCK_ID varchar(64) NOT NULL default '',
LOCK_TAB varchar(64) NOT NULL default '',
LOCK_BY varchar(96) default NULL,
LOCK_TIME datetime default NULL,
LOCK_SINCE datetime default NULL,
PRIMARY KEY (LOCK_ID,LOCK_TAB)
)
For Oracle:
CREATE TABLE PHPLENS_LOCK
(
LOCK_ID VARCHAR(64) NOT NULL,
LOCK_TAB VARCHAR(64) NOT NULL,
LOCK_BY VARCHAR(96),
LOCK_TIME DATE,
LOCK_SINCE DATE,
PRIMARY KEY (LOCK_ID,LOCK_TAB)
)
For maintenance, you should run a background job to scan the PHPLENS_LOCK table and delete all expired records, eg.
$sql = 'DELETE FROM PHPLENS_LOCK WHERE lock_time < '.
$DB->DBDate(time()-24*3600);
In-Record Locking
The above locking method does not require table structure modification. However if you want a higher performance locking solution, you should modify your table, adding the following fields:
LOCK_BY VARCHAR(96) LOCK_TIME DATETIME # or equivalent for your db
Then set in phpLens:
$lens->lockRec = 'USERID;LOCK_BY;LOCK_TIME';
The 2nd parameters is the table field that holds the userid of the person who is locking the record, and the 3rd parameter is the table field that holds the date and time that record was initially locked.
Lock Timers
Also see the lockTimers property. Basic:Yes Advanced/Enterprise:Yes DynamicEdit:Yes [Version 4.0]
|