Ask a Question related to PHP Development, Design and Development.
-
Felix Natter #1
implement locking
hi,
I would like to lock a record so that when one user is modifying a
particular record, then it is locked for all other users. For this
purpose, I have two fields in every table ("LockedBy int null", which
contains the UserID of the editing user and "LockedSince int not
null", a timestamp).
My current logic is: when the user enters the form to modify a record,
lock it (set LockedBy=$UserID). when the user presses the submit-button
to commit his/her changes, unlock the record.
The problem with this is that the user may press fwd+back buttons of
the browser. So either I find a way to disable these in the
editing-forms or I need to find a different way to do this
Of course I could use a timeout (by using LockedSince-field) for cases
where one form has been locked for > 2 hours, but that alone is not
enough (I can't always lock records for that long!)
thanks in advance,
--
Felix Natter
Felix Natter Guest
-
Implement XFORMS on ASP
Hi, I'm looking for a means to generate hundreds of ASP webforms using declarative language. I've put my attention on XFORMS. I understand... -
How to implement a MXP
Like everything, this started simply. I want to provide breadcrumb navigation to my site. Thus after a little research I found two references:... -
How to implement Tracing!!
Hello, I want to print some trace messages in my webservice. If I debug asp_net through VS.net wp I would like to see those trace messages. ... -
Need Direction on WHAT to Implement...
Please understand that I am not asking HOW to do something - but, rather, I just need some advise on what "technology" or method I should... -
How to implement counter?
There are many ways to do this. The low tech low impact way is the create an application variable inthe Application start, that reads in a value... -
Andy Jeffries #2
Re: implement locking
On Mon, 11 Aug 2003 16:06:47 +0200, Felix Natter wrote:
You can't.> The problem with this is that the user may press fwd+back buttons of
> the browser. So either I find a way to disable these in the
> editing-forms or I need to find a different way to do this
That sounds wise (along with a BREAK LOCK link so that users can click it,> Of course I could use a timeout (by using LockedSince-field) for cases
> where one form has been locked for > 2 hours, but that alone is not
> enough (I can't always lock records for that long!)
see that "John Smith locked this record 50 minutes ago, do you want to
break the lock?").
Cheers,
Andy
Andy Jeffries Guest
-
Paul Liversidge #3
Re: implement locking
Felix Natter <fnatter@gmx.net> wrote in message news:<m3ekzsxp8o.fsf@werkstatt4.ldc>...
If you really need locking then perhaps you need to use a different> I would like to lock a record so that when one user is modifying a
> particular record, then it is locked for all other users. For this
> purpose, I have two fields in every table ("LockedBy int null", which
> contains the UserID of the editing user and "LockedSince int not
> null", a timestamp).
>
> My current logic is: when the user enters the form to modify a record,
> lock it (set LockedBy=$UserID). when the user presses the submit-button
> to commit his/her changes, unlock the record.
>
> The problem with this is that the user may press fwd+back buttons of
> the browser. So either I find a way to disable these in the
> editing-forms or I need to find a different way to do this
backend database that does support row locking otherwise the best
you'll ever achieve is a kludge.
If you have problems with your 'locks' being released you could add to
your logic that a lock can't be held if the user has moved off that
page. It would still mean that if the user clicks on edit and then
goes to lunch, goes home or closes their browser the lock would still
be active.
If you wanted to get really fancy you can have a page that constantly
reports the page is open and the lock is still required.
You place a 1px by 1px image in the page but change the source to
refer to a PHP page, i.e. keeplock.php. You then add some JavaScript
to the page that reloads the image every 30 seconds or so.
In the keeplock.php, you update your locking field to reflect the new
time and then send a header ("image/gif") and the contents of a blank
1px by 1px gif.
If the browser does go back or shutdown the lock will not be updated
and you can safely release the lock.
It still doesn't help if they leave the edit page on their browser
when they go to lunch or go home but a smack round the head with a
large wet tuna may help to remedy that problem.
Paul
Paul Liversidge Guest
-
Re: implement locking
In article <bf26a194.0308111155.40b7cf0a@posting.google.com >,
Paul Liversidge <paul_liversidge@hotmail.com> wrote:
How would that help? The real problem is the read/update>If you really need locking then perhaps you need to use a
>different backend database that does support row locking
>otherwise the best you'll ever achieve is a kludge.
cycle when using a web interface. You just can't be
sure that the user that locked the record will *ever* return
the lock. It's not an easy problem to solve.
--
[url]http://www.spinics.net/lists/phpdb/[/url]
Guest
-
Jochen Daum #5
Re: implement locking
Hi felix!
On 11 Aug 2003 16:06:47 +0200, Felix Natter <fnatter@gmx.net> wrote:
I would use optimistic locking with web interfaces. This means you>hi,
>
>I would like to lock a record so that when one user is modifying a
>particular record, then it is locked for all other users. For this
>purpose, I have two fields in every table ("LockedBy int null", which
>contains the UserID of the editing user and "LockedSince int not
>null", a timestamp).
>
have fields:
"LastUpdatedBy" and "LastUpdatedDateTime"
Also, you keep in mind when you read it for editing.
When you save and someone else saved it meanwhile, you give a warning
"Someone else changed the record, etc pp.". With some knowlegde about
the table or a "before image" you may alsoi be able to merge the
records automatically.
HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
[url]http://sourceforge.net/projects/phpdbedittk/[/url]
Jochen Daum Guest



Reply With Quote

