tags:

views:

45

answers:

4

Hi, I am making a doctor appointment slot booking mechanism,where in doctor appointment 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.

+1  A: 

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

Epitaph
A: 

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.

Radek Šimko
A: 

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.

AJ
A: 

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.

mbeckish
cant it be asynchronous with out updating or inserting a column in table...on click of the radio button juts send some msg to server and do it.
pradeep
You can use AJAX to send the request from the user to the server. However, you need some centralized mechanism that supports threadsafe, atomic operations to do the locking. The DB is an easy place to do this, because it is built to support atomic operations in a threadsafe manner.
mbeckish