Take a look at the doctrine docs Concurrency and Transactions, there are a few options that you could use.
I would agree that optimistic locking is probably the way to go, but you wouldn't have to change your current logic. Just add a new version
field (type serial
is best) to the entity you want to insert into, and when you do your initial SELECT, you pass in the unique version number. Then when you insert, if the version has changed, you know that someone else has already booked and the insert will not happen.
The docs have some good examples there for Optimistic Locking
UPDATE
Optimistic locking will work when updating the entity. For inserting a new entity, transactions will be the best bet.