tricky design problem

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
nnranger
Forum Newbie
Posts: 3
Joined: Tue Nov 11, 2003 9:43 pm
Location: newport news, virginia, us

tricky design problem

Post 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!
:?
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post 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.
nnranger
Forum Newbie
Posts: 3
Joined: Tue Nov 11, 2003 9:43 pm
Location: newport news, virginia, us

solution noted

Post 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
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post 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.
nnranger
Forum Newbie
Posts: 3
Joined: Tue Nov 11, 2003 9:43 pm
Location: newport news, virginia, us

thanks again

Post 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,
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post 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.
Post Reply