Hi all, We have designed a web site as an assignment (please read the rest) and came to the final step. This step includes a concurrency control. Let me explain the situation with an example. In the system the user "doctor" assigns tests for a "patient", then, when any "lab technician" logs in the system he can see the patient name and the test assigned. In this case two or more technicians may try to submit the test result at the same time. For that reason we have to detect which technician clicked the submit button first (Actually it is not submit button but we have to detect which technician clicked the link of "submit result page" first). So the other results of the technicians can be rejected. We tried adding a flag attribute in the database (MySQL) but it didn't work. Then we tried a text read/write operation as a flag holder but again we were not successful. We saw a general solution called Peterson's solution but we could not manage to put it in PHP code (we have to think also multi user case of Peterson solution). Any kind of suggestion/help is appreciated. Thanks.
Just add a timestamp field to your database then. So when the technical clicks the link and updates the database with the test result, it also stores the exact date/time they did it. Then you can review the data manually or put in some code that will go through an analyze the test results and clear up the data.
Perhaps we can talk to the lecturer for this solution, but, as far as I know the resolution of the timestamp in MySQL is in seconds. IMHO, this is not a good idea for very small access times. Am I wrong?
okay but then there is only one patient in a test result right? why not check for that patient ID or make it unique.
You can store a timestamp, which is a large integer yes. Alternatively you could use a datetime field, which stores it like this: "2010-05-15 11:41:43".