我有一张有时间栏的桌子。
CREATE TABLE `mbusGuestCodeExpires` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`hashOfUser` int(11) NOT NULL,
`expiresTime` time DEFAULT NULL,
`active` int(1) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `hashOfUser` (`hashOfUser`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 PACK_KEYS=0;
输入该字段的值并且用户可以更改它,其中
$expireTime
是来自表的时间,$timeDiffHour
和$timeDiffMinute
是来自表的时间。 echo "<div class='expires'>Expires:<input type='text' class='expiresTime' value='{$expireTime}'/></div><div class='left'>";
if (($timeDiffHour>=0) && ($timeDiffMinute>0))
{
echo"Left:".$timeDiffHour."h. ".$timeDiffMinute." min.";
}
echo"</div>";
我现在需要在
$expireTime
时间时将活动字段更改为0。除了每分钟运行cron脚本检查所有列并在当前时间较短时检查其值之外,最好的方法是什么? 最佳答案
怎么样:
select ... where expiresTime < curtime()
文件参考号:http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_curtime
关于php - 按时间更改sql表值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27551277/