php - Ajax/JQuery database access/mutex -


i have created office scheduling program uses jquery post php file inserts appointment pgsql database. has not happened yet can foresee problem in future--two office workers try schedule appointment in same slot @ same time, creating race condition , 1 set of customer data lost, or @ least i'd have dig out of log. wondering if there flag set in database, if need create kind of gatekeeper program control server connections, or if there kind of mutex/lock/semaphore can use javascript/php/sql keep race condition occurring.

you can either lock database flag, or better strategy detect collisions, since happens in rare cases.

to detect problem, can save timestamp database containing last updated time. send along form, , compare timestamp before update record. if timestamp has changed, present user data , ask them want do. offers way second saving user modify changes based on saved data if wish.

there other ways solve problem, , proper solution depends nature of specific problem.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -