You can't really protect from concurrent updates at the PHP level. This
problem is normally solved by using the MySQL two-phase commit
mechanism: acquire all the data needed for the update, start a MySQL
transaction, update the DB, then commit the update. See
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-transactions.html
-- Walt
Kirk Ouimet wrote:
Hi List,
I am currently storing an object in a MySQL database. The object is
continually being updated by many (possibly simultaneous) requests. Workflow
looks something like this:
1. Data comes in from one of many sources
2. PHP reads the object from the database
3. PHP adds data to the object
4. PHP writes the object back to the database
I think I'm running into a concurrency issue where I have record of new data
being received, but the database object does not reflect the new data. I
feel like I need to make the object a mutex but I have no idea how to go
about doing that with PHP. Can anyone provide alternative designs that will
be a little more robust and handle concurrency?
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net