PHP 多个不同日期和时间的预订数据
我有一个预订系统,有很多会员网站,这些网站提供信息,允许人们使用我们的网站向他们预订。
对于每个会员,我们需要知道他们可以预订的日期、星期几以及这些天的时间。此信息不会随着预订数量的变化而变化。
问题是一些会员可能允许全年上午 9 点至下午 6 点之间进行预订。而其他人可能会根据一年中的不同时间和一周中的不同时间有不同的预订时间和日期。
实际上所需要的东西是这样的:
<dateperiod>
<weekday>
<times>
<price>
<times>
<weekday>
<dateperiod>
所以填充的可能看起来像这样。
<dateperiod>January,February,March
<weekday>Mon,Tue,Wed,Thu,Fri
<times>6-12
<price>25<price>
<times>
<times>12-18
<price>40<price>
<times>
<weekday>Sat,Sun
<times>6-13
<price>45<price>
<times>
<times>13-17
<price>55<price>
<times>
<weekday>
<dateperiod>
现在它看起来很像 XML 提要。这不是我的意图,而是需要在管理面板中为每个成员创建并由每个页面上的预订系统提取的数据结构。
我们究竟是如何实现这样的目标的?
有什么想法吗?
I have a system for booking with lots of member sites that offer information to allow people to use our site to book with them.
With each member we need to know the dates, days of the week and times during those days they are available to book. This information does not change with number of bookings.
The problem is some members may allow bookings all year around between 9am and 6pm. Whilst others may have different booking times and days depending on the time of year and different days of the week at different times of the week.
Effectively what is needed is something like this:
<dateperiod>
<weekday>
<times>
<price>
<times>
<weekday>
<dateperiod>
So one that is filled in might look like this.
<dateperiod>January,February,March
<weekday>Mon,Tue,Wed,Thu,Fri
<times>6-12
<price>25<price>
<times>
<times>12-18
<price>40<price>
<times>
<weekday>Sat,Sun
<times>6-13
<price>45<price>
<times>
<times>13-17
<price>55<price>
<times>
<weekday>
<dateperiod>
Now that looks suspiciously like an XML feed. Not my intention but that is the kind of data structure that needs to be created in the admin panel for each member and extracted by the booking system on each page.
How the hell do we achieve something like this.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您使用的是 MySQL,则应使用以下结构:
months set('January', 'February', ..., 'December') not null
工作日设置('星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日') 不为空
hours_from tinyint(2) unsigned not null default 9
// 如果您需要分钟,也可以是其他类型hours_to tinyint(2) unsigned not null default 18
// 同上price Decimal(3,2) not null
...而您的 WHERE 语句将如下所示:
Assuming you're using MySQL, the following structure should do it:
months set('January', 'February', ..., 'December') not null
weekdays set('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') not null
hours_from tinyint(2) unsigned not null default 9
// could be other type if you need minutes, thoughhours_to tinyint(2) unsigned not null default 18
// same as aboveprice decimal(3,2) not null
... and your WHERE statement would be something like this: