-----Original Message-----
>Does anyone know a good way of locking out access to a record on a
>MySQL database when someone has the update page open? The problem is
>that we have a local intranet site which is accessed by members of
>different departments. Now at the moment when someone loads the page
>all of the data is pulled into the form, and then when they submit, all
>of that data is passed back to the database, including anything they
>haven't changed.
<snip>
You should really rethink whether sending all those records is
necessary, or wise. Is the convenience of mass updates really worth the
headache?
>What we are trying to avoid is situations where for example someone
>leaves the form open on their computer and goes away for lunch. In the
>meantime someone else at a different station makes changes to the form.
>Then when the first person comes back from lunch, they submit the form,
>thereby writing over all of the second person's changes with the old
>data.
<snip>
My personal opinion on this:
Any database that's so simple/small that it should have its
entire contents updated every change, should only be managed by a single
person.
If that isn't an option, then the individuals should be
modifying individual records instead of the entire recordset. This
means a listing page, and selecting the record (or records, using
checkboxes) to update. This is where you can easily set your locking,
perhaps with a timestamp that will time out after X minutes, to prevent
users overwriting.
If neither of these are options, you have larger problems then you'll be
able to properly solve in a web environment. Forcing the browser to
re-display the page every minute [set the href explicitly, not reload,
in case of post/etc.] is something that should at least reduce the
chances of massive overwrite errors. Not that I particularly approve of
that method :) It is, however, a relatively functional solution - if
you're stuck with neither of the above as being options.
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php