你好,希望有人能帮我。
让我们说,我的桌子上有以下几个
名称文本startTime时间戳没有时区,endTime时间戳没有时区
以下是我要做的事:
我试图检查即将添加到数据库中的时间是否会与表上的时间重叠。
样本:
name startTime endTime
---------|------------------------|----------------------
tommy | 2019-07-10 08:30:00 | 2019-07-10 10:30:00
tommy | 2019-07-10 10:31:00 | 2019-07-10 11:30:00
tommy | 2019-07-10 07:30:00 | 2019-07-10 09:00:00 <=== if I click enter to enter this tird schedulle for this user, the sistem will give me a conflict message because this user already has a schedulle that start from 2019-07-10 08:30:00 to 2019-07-10 10:30:00 on our first row of the table.至于我要在数据库中插入的代码,我所拥有的只是这个简单的php。
$sql = "insert into horarios (name, startTime, endTime) values ('$name', '$startTime', '$endTime');";
$res = @pg_query ($con, $sql);
if ($res == NULL){
echo "Query failed.";
exit (0);
}https://stackoverflow.com/questions/63695789
复制相似问题