如果 $Time 为空,则在查询中将其替换为 ''。结果查询不正确。如何避免这个问题?
$Time = strtotime($arrivals[$i]["time"]);
if ($Time != null)
{
$Time = strftime("%Y-%m-%d %H:%M:%S", $Time);
}
$query="INSERT INTO `Schedule` (`Time`) VALUES('".$Time."');";
结果查询:
INSERT INTO `schedule` (`Time`) VALUES('');
但应该是:
INSERT INTO `schedule` (`Time`) VALUES(null);