Page 1 of 1

tricky design problem

Posted: Tue Nov 11, 2003 9:43 pm
by nnranger
I'm designing an online reservation system. The plan calls for setting a hold flag in a mysql table when a reservation is started, to prevent double bookings. I'm stuck on a way to reset records if a user abandons the attempt/closes out, etc. I am considering running php cmd line to reset where timestamp x time old. But...

Is there a way to access all running sessions, to view all session id's? I store the session id in the "shopping cart" and wanted to be able to cross reference that with open sessions. Is this possible? Am I way off base here?

Thanks!
:?

Posted: Wed Nov 12, 2003 3:07 pm
by JPlush76
If you're serious about doing a real reservation system I would suggest looking into using a different database. PostGreSQL for example already handles transaction login in the database itself...

IE if the system needs to complete 3 steps but only completes 2 then everything can be rolled back and that time slot becomes available again.

however if you want to view all session ids the best way would be to use a custom session class that logs the sessions into a database instead of using the text files which it does by default.

solution noted

Posted: Wed Nov 12, 2003 5:09 pm
by nnranger
Thanks! I was considering that as a possibility. Zend.com actually posted an article on how to log sessions into a db, and I might look into that.

BTW, I am using InnoDB tables in MySQL, which support transactions natively.

Chris

Posted: Wed Nov 12, 2003 5:16 pm
by Linkjames
Just a quick thought, but you could do it like this.

User starts a reservation, and it is flagged, with a timestamp.
When another user views the avalible flights/dates, whatever, the code checks for flagged items that were flagged over a certain amount of time ago and unflags them. Obviously just don't show flagged items.

pseudocode
Check if any items are flagged.
If yes, check if they are past time limit.
If they are, remove flag and proceed as normal.
If they are not, leave them and proceed.

I think that makes sense.

thanks again

Posted: Wed Nov 12, 2003 11:04 pm
by nnranger
Thank you everyone for the ideas, I do appreciate it greatly.

Yes, I had thought of something like that:

pseudocode:
When another user starts reservation then check if items on "shopping cart" are over a certain age, if so delete.

Also, call php cmd line with Cron job every 15 minutes to do the same.

I was just hoping for a more elegant solution.

Thanks,

Posted: Thu Nov 13, 2003 6:42 am
by Linkjames
How do you mean elegent? If you have the php check for old reservations and remove them at the start of your script it will be invisible to the user.