我有一个数据库与物品保留。所有预订都有:ID,物品ID,personWhoBookedId,time_from(unixtime),time-to(unixtime)。mysql数据从日历检查,如果预订
我喜欢每小时显示一天的时间安排,并为该项目预订的时间上色,并在该时间范围内显示personWhoBookedID。
喜欢:
room1:
5:00 - 6:00: free
6:00 - 7:00: booked by[person]
8:00 - 9:00:free
和
room 2:
5:00 - 6:00: free
6:00 - 7:00: booked by[person]
8:00 - 9:00: booked by[person]
等
在这个时候,我通过与MySQL的现有项目迭代,然后按时间表检查与MySQL,如果是有预约的是等于所提及的时间范围之间的itemID和时间 - from和time-到
这可以工作,但是会在数据库上做很多查询。
为了提高性能,我想我最好弗里斯特得到全部保留,并将它们,存储在一个多维数组是这样的:
$allreservationsperday = mysql_query("select id, personid, itemid, time_from, time_to FROM reservations where time_from >= '$unixfrom' and time_to < '$unixto'");
while($reservationarray = mysql_fetch_array($allreservationsperday)){
$res[$reservationarray ["id"]]["personid"] = $reserveringenarray["personid"];
$res[$reservationarray ["id"]]["itemid"] = $reserveringenarray["itemid"];
$res[$reservationarray ["id"]]["time_from"] = $reserveringenarray["time_from"];
$res[$reservationarray ["id"]]["time_to"] = $reserveringenarray["time_to"];
}
,然后通过for循环的时间显示时间轴循环当天 但我不知道如何检查每小时是否在刚刚形成的数组中有预留。
任何帮助最受欢迎! jeroen
2010-01-26
Jeroen
+0
@Jeroen - 你一对夫妇可能与“预订系统”的帖子的: HTTP:/ /stackoverflow.com/questions/1692969/booking-system-dates-in-database/1693079#1693079和http://stackoverflow.com/questions/1687519/searching-for-availability-with-mysql-and-php/1691282 #1691282 –
2010-01-26 23:35:40