Comment Verify Original Values Didn't Change (Score 1) 283
1. User selects a row to edit. Application pulls all the columns for that row and stores them into the users session.
2. User makes modifications to some fields and submits back to the server.
3. Server issues an UPDATE statement and includes all the original column values in the WHERE clause to only update the record if nobody else has modified it since we started.
SELECT id, color, name, description FROM vehicle WHERE id = '100'
id = 100
color = 'red'
name = 'kia'
description = 'cheap'
User changes the color to 'blue' and saves changes, the app might do something like:
UPDATE vehicle SET color='blue' WHERE id=100 AND color='red' AND name='kia' AND description='cheap'
If anyone else modified a field in the row the update would fail and you can handle it however you like.