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.
mutual exclusion in PHP
Moderator: General Moderators
- PHPHorizons
- Forum Contributor
- Posts: 175
- Joined: Mon Sep 14, 2009 11:38 pm
Re: mutual exclusion in PHP
Are you using a database for this?
Re: mutual exclusion in PHP
Sounds like you want optimistic locking. See http://pooteeweet.org/blog/1552 for example of optimistic locking in php/mysqlkays_f wrote: Any kind of suggestion/help is appreciated.
Re: mutual exclusion in PHP
+1 on Weirdan suggestion and also you can look for more information about locking mechanism and strategies here for Innodb:
http://dev.mysql.com/doc/refman/5.0/en/ ... s-set.html
and here:
http://dev.mysql.com/doc/refman/5.0/en/ ... modes.html
http://dev.mysql.com/doc/refman/5.0/en/ ... s-set.html
and here:
http://dev.mysql.com/doc/refman/5.0/en/ ... modes.html