1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Concept of Holding a reservation.

Discussion in 'PHP' started by theextelligence, May 26, 2011.

  1. #1
    Hi

    I was wondering how do you implement the concept of holding a registration of an event or a booking?

    For instance, when you try to book a hotel room or a try to book a air ticket online, they hold your registration for say 10 or 15 mins, during which the room or seat will be locked for that time and once the time expires, they release the holding.

    A real life example would be events hosting on eventbrite

    http://collaboratemumbai-ehometext.eventbrite.com/
    Code (markup):
    How do we implement the same concept in an PHP application?



    Any help will be greatful.


    Thanks
     
    theextelligence, May 26, 2011 IP
  2. TSelbeck

    TSelbeck Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are many ways to explain this, however it really is simple.

    Let's use the hotels example. Let's assume there is a database, with a table called `rooms` (room_number, beds, etc), and `bookings` (booking_id, room_number, customer_name, customer_telephone, booking_time... etc)

    When a booking is made, a new row is inserted into the `bookings` table.

    However, if you're wanting a room to be held.. you could add a new field to the `bookings` table, such as 'confirmed'. If set to 1, the booking is confirmed and paid for and everyone is happy. If set to 0, the booking is unconfirmed. The 'booking_time' field will store the timestamp when the booking was created.

    You could then include a script in the header section of your file to delete all bookings from the `bookings` table, where the timestamp is say.. lower than time()-1800 and the 'confirmed' is set to 0.

    I guess that's the basic principle. But ideally, you'd need to work with sessions or cookies to validate the user, to make sure if they return within the alloted time, they can still make the booking.

    :)
     
    TSelbeck, May 27, 2011 IP
  3. theextelligence

    theextelligence Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Hi Again

    I have implemented the concept and it works like a charm except for one case. Our QA team has discovered an issue and I am not sure if this is the problem of the code or the database queue request.

    Our QA team are testing this by clicking on the "Check Room Availability" button simultaneously on 2 different computers at a single point of time. 2 out of 20 times they succeed in breaking the rule.

    For example, for 10th July 2011 only 1 room is available in a hotel. If we proceed with booking this room for the aforesaid date, the application holds the reservation for 15 mins for that user. But if the "Check Room Availability" button is clicked by 2 users at the same point of time, the rule fails 2 times out of 20 attempts.

    What do you think the cause of this and how can we prevent it?

    Any suggestion will be highly appreciated.


    Many thanks in advance.
     
    theextelligence, Jun 10, 2011 IP
  4. theextelligence

    theextelligence Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    HI Again

    I have an interesting question regarding the concept of holding a reservation.

    Suppose a registration is being held for a user for 20 mins, he fills up all the required forms (lets assume he spends 15 mins filling up the forms), after that the application takes him to the payment gateway page, where he spends 6-7 mins filling up teh credit card details, name etc.

    In the meanwhile a CRON which is set to run every 20 mins, deletes the record of that user from the database since the user has spent more than 20 mins for completing the whole process.

    After making a successful payment, when the user is redirected back to the application, the application does not find the matching record and displays an error to him saying your session has timed out etc.

    How would you handle or make the application handle such a case where the user has already made the payment?

    Any help / ideas will be highly appreciated.
     
    theextelligence, Jun 27, 2012 IP
  5. liquidfire

    liquidfire Greenhorn Affiliate Manager

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #5
    Another good read would be to check out the php class called "WHEN" find it on github here: github.com/tplaner/When

    it even supports ical format which is great if you have listings and such that reoccur.
     
    liquidfire, Jun 28, 2012 IP