473,782 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "LockedSinc e int not
null", a timestamp).

My current logic is: when the user enters the form to modify a record,
lock it (set LockedBy=$UserI D). 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
Jul 16 '05 #1
4 3222
On Mon, 11 Aug 2003 16:06:47 +0200, Felix Natter wrote:
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
You can't.
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!)


That sounds wise (along with a BREAK LOCK link so that users can click it,
see that "John Smith locked this record 50 minutes ago, do you want to
break the lock?").

Cheers,
Andy
Jul 16 '05 #2
Felix Natter <fn*****@gmx.ne t> wrote in message news:<m3******* *****@werkstatt 4.ldc>...
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 "LockedSinc e int not
null", a timestamp).

My current logic is: when the user enters the form to modify a record,
lock it (set LockedBy=$UserI D). 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


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.

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
Jul 16 '05 #3
In article <bf************ **************@ posting.google. com>,
Paul Liversidge <pa************ *@hotmail.com> wrote:
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.


How would that help? The real problem is the read/update
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.

--
http://www.spinics.net/lists/phpdb/

Jul 16 '05 #4
Hi felix!

On 11 Aug 2003 16:06:47 +0200, Felix Natter <fn*****@gmx.ne t> wrote:
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 "LockedSinc e int not
null", a timestamp).


I would use optimistic locking with web interfaces. This means you
have fields:

"LastUpdate dBy" and "LastUpdatedDat eTime"

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.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4564
by: Michael Chermside | last post by:
Ype writes: > For the namespaces in Jython this 'Python internal thread safety' > is handled by the Java class: > > http://www.jython.org/docs/javadoc/org/python/core/PyStringMap.html > > which has almost all of it public methods Java synchronized: > > http://cvs.sourceforge.net/viewcvs.py/jython/jython/org/python/core/PyStringMap.
1
2083
by: ionel | last post by:
is there a cross-platform library or module for file locking? or at least a win32 implementation. i'm trying to get a lock on some file in a cgi script. ( i got my data erased a few times :P ) -- ionel.
16
8932
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
10
11915
by: McFly Racing | last post by:
Thread Locking In Static Methods I have the need for a Log Manger class that has static methods. Normally I would use the lock statement or a Monitor statement both of which take a reference to (this). In the case of these static methods I am not able to do that.
15
6202
by: z. f. | last post by:
Hi, i have an ASP.NET project that is using a (Class Library Project) VB.NET DLL. for some reason after running some pages on the web server, and trying to compile the Class Library DLL, it can't compile because the DLL is in use (and the PDB too), and the w3wp.exe process is the process locking the DLL (as viewed with Sysinternals - Process Explorer). this is a huge problem. i need to do IIS reset in order to free the DLL! 1. why is...
7
2865
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets send the messagetype via async NetworkStream ns = client.GetStream(); //assume client globally accessible
0
1323
by: xpding | last post by:
Hello, I have a class MyEmbededList contains a generic dictionary, the value field is actually the MyEmbededList type as well. There is another class need to access and manipulate a list of MyEmbededList (please refer to the MyTestClass below). I am not sure whether I implements the right locking mechanism here and hope someone can give me some advices. I have provided some codes for these two classes below. My questions are: 1. Am I...
0
4101
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access with "No locks" as the default, so that optimistic record locking should take place, and "Open databases using record-level locking" is selected. Each Java thread gets a new connection to the database, then updates its record. One of my users has...
1
2227
by: Paul H | last post by:
I have an Employees table with the following fields: EmployeeID SupervisorID Fred Bob Bob John Bob Mary Bill Bill I have created a self join in the relationships window, with
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.