Php 时段预订系统
我需要用PHP和MYSQL创建一个在线预订系统,但在创建数据库表结构时,我总是遇到麻烦 这是我到目前为止的表结构:pseudoPhp 时段预订系统,php,mysql,Php,Mysql,我需要用PHP和MYSQL创建一个在线预订系统,但在创建数据库表结构时,我总是遇到麻烦 这是我到目前为止的表结构:pseudo TABLE: 'times' time_id | int | AI time | datetime? (is this the best approch, if so how would the PHP code look for the datetime format?) available | boolean TABLE: 'bookings' bookin
TABLE: 'times'
time_id | int | AI
time | datetime? (is this the best approch, if so how would the PHP code look for the datetime format?)
available | boolean
TABLE: 'bookings'
booking_id | int | AI
client_id | int | foreign key
manager_id | int | foreign key
time_id | int | foreign key
在系统中,我希望能够:
在管理面板中创建一个新日期,然后系统用户可以创建一个可用的预订时段。
时间只能是以下选择之一:这是我困惑的地方,我是否应该将下面的时间之一存储为DATETIME或Unix时间戳等
3:05
3:10
3:15
3:20
3:25
3:30
3:35
3:40
3:45
3:50
3:55
4:00
4:05
4:10
4:15
4:20
4:25
4:30
4:35
4:40
4:45
4:50
4:55
5:00
5:05
5:10
5:15
5:20
5:25
5:30
5:35
5:40
5:45
5:50
5:55
六点
有人能帮我吗
提前谢谢。我自己更喜欢unix时间戳:,这样我就可以存储为整数。-Edit- 根据最近的编辑,您似乎希望显示预设时间的选择列表,然后将选定时间插入数据库。如果这是正确的,那么时间戳对您没有帮助,因为时间戳是从1970年1月1日到2038年1月19日的特定时间实例
对于您的示例,我们可以硬编码时隙,考虑以下内容:
class Time
{
const TIMESLOT_MIN = 3;
const TIMESLOT_MAX = 6;
public static function getTimeslots()
{
$timeslots = array();
for ($i = self::TIMESLOT_MIN ; $i <= self::TIMESLOT_MAX ; $i++) {
for ($j = 0 ; $j < 60 ; $j +=5) {
if ($j < 10) {
$j = '0'. $j;
}
$timeslots[] = $i . ':' . $j;
}
}
return $timeslots;
}
}
var_dump(Time::getTimeslots());
为了将来,请使用管道而不是-,格式化表列。使其更易于阅读。添加管道,感谢您的建议。您在回答中谈到时间,然后定义日期时间。在MySQL中存在。预订表是否应该是times表的外键?如果是,泰晤士报和预订是否是1:1的关系?还有计算字段吗?@danihp:我刚刚修改了我的问题,你能看一下吗,伙计?谢谢@Matthew。我现在将研究unix时间戳数据类型。我刚刚修改了我的问题,你能看一下吗,伙计?我刚刚修改了我的问题,你能看一下吗,伙计?@JoelMurphy:更新的解决方案。
ON UPDATE CURRENT_TIMESTAMP