Editing locked by another user

Created: Oct. 15, 2013 Updated: Sept. 29, 2026

A simple CRUD works great as long as one person edits a record.

In tutorials CRUD looks simple: a list, a form, save. In a real system two people can open the same record, each fixes something, saves, and whoever saved last wins, while the first person's changes quietly disappear. Nobody gets an error, the data is just different from how someone left it.

In the PHP system I'm working on now, this is solved with a lock. The first person who starts editing a record locks it. The second one, on opening it, sees that editing is locked by another user, and can send them a request to release it with a button.

A lock solves overwriting, but straight away creates a new problem: someone opens a record, goes to a meeting or home, and the record stays locked. Without the release request you'd have to walk around the office looking for that person, probably in the kitchen by the coffee machine :-)

#crud #wielodostep #php

Machine-translated from Polish (original).