旅游网站如何锁定房间? [英] How travel sites lock room?

查看:61
本文介绍了旅游网站如何锁定房间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用酒店预订系统(PHP,MySQL),但我想不出锁定房间的最有效方法(防止同一房间预订超过同一日期的预订) 20分钟,如果访客在该时间内未付款,则将其释放.该系统可能会变得很大,所以我想确保它尽可能高效.

I'm working on a hotel booking system (PHP, MySQL) but I can't figure out the most efficient way to lock rooms (prevent the same room from being booked more than its allotment on the same date) for just 20 mins and release it if visitor doesnt make payment within that time. The system can grow large so I'd like to make sure that it's as efficient as it can be.

任何建议将不胜感激.

谢谢.

推荐答案

我将在数据库中使用一个简单的时间戳字段来表示已锁定".每当有人尝试预订房间时,该软件都会将当前时间与时间戳进行比较,如果该时间大于20分钟且尚未付款,则锁定无效.

I would use a simple time stamp field in the database to indicate"locked". Whenever someone attempts to book the room, the software compares the current time with the timestamp, and if it is > than 20 minutes and the payment has not been made, the lock is not valid.

此方法可能足够有效.时间戳通常为32位,并且对数据库调用的性能影响可以忽略不计.

This method is probably sufficiently efficient. A timestamp is usually 32-bits and the performance hit on the database calls with comparison negligible.

这篇关于旅游网站如何锁定房间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆