开发者

slot booking problem

开发者 https://www.devze.com 2022-12-30 01:52 出处:网络
I am making a doctor appointment slot booking mechanism,where in doctor appoin开发者_JAVA百科tment slots will be divided into 30 mins slot each...i have achieved all the working code.. 1 problem i am

I am making a doctor appointment slot booking mechanism,where in doctor appoin开发者_JAVA百科tment slots will be divided into 30 mins slot each...i have achieved all the working code.. 1 problem i am facing is that..this booking is made at 2 places i.e 2 receptions..so when 1 selects a slot(radio button) not yet confirmed and saved in DB.other reception must not be able to select .how do i do it.any help on this...how do i go abt it.


This is a case of accessing "shared data". You'll need thread to make sure that only one thread has access to the data at a time to ensure it's integrity. The following might provide some ideas http://www.alternateinterior.com/2007/05/communicating-with-threads-in-php.html


I would use some AJAX/AJAJ functions to periodically refresh data about free slots, or I would do that much more simple - when saving the appointment, just check it, if the slot will be taken, your app redirects user back to form to choose another slot.


In essence,

  • I will just ask for the slot timings upfront and the remaining details later.

  • In case the slot is available, it sends a request to the server to lock it, so that the other client cannot use it.

  • In case, it is not available, it will receive a small notification that this slot is unavailable, click to see available slots.

I would go with AJAX (if this is a web app). This is a distributed systems problem which resembles Blue Army - White Army problem.


Add a "Locked By" field to the table. When booking a slot, do something like:

UPDATE tablename
SET LockedBy = userid, ...
WHERE LockedBy IS NULL

After the update, you can select to see if LockedBy is set to your userid. If not, then someone else must have beaten you to the punch, and you need to tell the user to pick a different slot.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号