J
|
Jane 2/13/2009 |
John, global $strTableName,$strWhereClause,$conn; $rs = CustomQuery("select IsLocked, LockTime, UserField from ".$strTableName." where ".$strWhereClause); $datatmp = db_fetch_array($rs); if ($datatmp["IsLocked"]==1 && (strtotime("now")-strtotime($datatmp["LockTime"]))/60<20) { echo "This record is in use by ".$datatmp["UserField"]; } else { //lock record here $str = "update ".$strTableName." set IsLocked=1, LockTime=CURDATE(), UserField='".$_SESSION["UserID"]."' where ".$strWhereClause; db_exec($str,$conn); }
global $conn; $strUpdate = "update TableName set IsLocked=0, LockTime=now() where ".$where; db_exec($strUpdate,$conn); |
S
|
shoppy author 2/16/2009 |
John, This schema requires two additional fields in the database table to implement record locking. IsLocked - Yes/No field, LockTime - Datetime field, UserField - username. Timeout is set to 20 minutes. Use Edit page: Before display event on the Events tab to lock record. Here is a sample: To unlock the record use Before record updated event:
|
J
|
Jane 2/16/2009 |
Hi, $rs = db_query("select IsLocked, LockTime, UserField from ".$strTableName." where ".$strWhereClause,$conn); |
![]() |
hichem 2/17/2009 |
Hi Jane, |
S
|
shoppy author 2/17/2009 |
No, exactly the same here. |
![]() |
hichem 2/17/2009 |
HI Jane, |
S
|
shoppy author 2/18/2009 |
I finally uploaded the whole lot to the demo account. |
N
|
nix386 2/18/2009 |
I finally uploaded the whole lot to the demo account. So now it's time to just wait till Jane fix this problem. I am sure she can and will. regards, John
|
S
|
shoppy author 2/18/2009 |
The last things I heard from Jane where these remarks:John, please make sure you use NOW() function in your "BeforeShowEdit" and "BeforeEdit" events. CURDATE() function return date only (with time).
|
![]() |
hichem 2/18/2009 |
I tried a few things for a few hours but didn't get this to work. |
S
|
shoppy author 2/19/2009 |
Ok, I got it so far that it says: "The record is in use by .. (the user)".
|
S
|
shoppy author 2/19/2009 |
Jane asked me step by step what I want and what didn't work.
|
![]() |
hichem 2/19/2009 |
spot on John! I am sure Jane will have a clever solution as usual. |
S
|
shoppy author 2/19/2009 |
Hi Hich,
|
![]() |
hichem 2/19/2009 |
Cheers John, |
S
|
shoppy author 2/19/2009 |
Hi Hich, |
I
|
imendes 2/20/2009 |
Ok, now the record is locked, and I get the warning message. |
N
|
nix386 2/20/2009 |
Hi Hich, I copied the code directly from my Eventpage so there is nothing to add or change. I don't use the inline edit and therefore I didn't encounter your problem, sorry mate really would like to help. Only problem I now have is the agenda (calendar). Probably did something wrong here. John
|
J
|
Jane 2/20/2009 |
Isildo, |
S
|
shoppy author 2/21/2009 |
I encountered the same problem with going back to the list while NOT saving. |
![]() |
hichem 2/22/2009 |
I encountered the same problem with going back to the list while NOT saving. Is it not possible to lock the record for as long it is in use and after leaving the edit field (saved or not) just unlock it for every one to use? John P.S. for the time being I just took the 'back to list' button away <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=38132&image=1&table=forumreplies' class='bbcemoticon' alt='<<' />
|