At 11:12 AM -0400 7/17/09, Jason Pruim wrote:
Hi everyone!
So some of you may have noticed that I have been away for quite
awhile... Been trying to get settled (Moved across the country) and
getting a job.
And now that that is done I have a question about a project that I
might be doing for my current employer and want to do it properly.
If all goes through, I'll be writing an online database that upwards
of 10 people will be using at various times through out the day.
Basically, in a form they fill out a model number, customer name,
phone number etc. etc.. And then submit the form. After submitting
they need to write the log number on some paperwork. If I have 2
people submit the form at the same time, I'm thinking I could end up
with a race condition and they might get the wrong log number (The
log number is simply a consecutive record number)
Do I need to be reading up on locking tables/rows? Or in my
situation as I've briefly described it do I not have to worry about
it? Or is there a third door with the magic bullet that will solve
all my problems? :)
Any advice is greatly appreciated as always, RTFMing is good as
well, as long as M is defined :)
I'm not afraid of google either, just need the right terms to hit it
with so I don't go into "search overload" as the commercials for a
rival search engine claim :)
Thanks Everyone!
Jason:
Welcome back.
Clearly if you have two or more people checkout the same record at
the same time and each edits the record then you ARE going to have
problems when each updates the record.
You can solve this problem by using transactions -- here's a link:
http://dev.mysql.com/doc/refman/5.0/en/lock-tables-and-transactions.html
When someone is editing a record, you also need to be able to show
the next person(s) that the record they want is currently busy and
not available. However, I'm not sure as to how to notify the next
user that the table is locked via php. Perhaps a table status might
provide that information. If so, then use that to notify the next
user.
As for your log of activity, just create a another record (with an
auto_increment index) in your activity log table and update that
record with the data you need to record, such as user id, timestamp,
what record they accessed and whatever else you want after the
transaction is completed.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php