Ok the answer to this quesiton is probably obvious but it is bothering me.
So I am wiriting a script that many people will be adding data to at the same time.
The script basically runs a select statement get a row of data take one cell out then adds a value to the value from that cell and then runs an update statment to put that new data in the database.
My worry is what happens if two people do this at the same time and there select statments both run before one of the users update statement the second person will then be adding to a smaller number then they should be and messing up the data.
Is this a concern or is there automatic locking in php and mysql that will not allow this to happen.
If there isn't should I use something like LOCK TABLE X WRITE or something to that effect?
MYSQL Select/Update Lock Question
Moderator: General Moderators
Probably you do not need to select the value.tbrown1 wrote:The script basically runs a select statement get a row of data take one cell out then adds a value to the value from that cell and then runs an update statment to put that new data in the database.
Code: Select all
UPDATE tablename SET fieldname=fieldname+4711 WHERE id=1234