可以使用MySQL
,PHP
,和CRON
做到这一点
首先,创建一个关系表 -
CREATE TABLE `test_expiry` (
`userid` int(2) unsigned NOT NULL, // user that is taking the test
`testid` int(2) unsigned NOT NULL, // test number
`expires` datetime NOT NULL); // date/time test will expire
//change names/types as needed/to match your db structure
其次,设置is_available
= 1时,该测试添加到test_expiry
表
INSERT INTO `test_expiry` (`userid`,`testid`,`expires`) VALUES (:userid,:testid,:expires)
三,创建一个php页面,将更新is_available
= 0,如果日期/时间已过。
SELECT `userid`, `testid` FROM `test_expiry` WHERE `expires` < NOW()
foreach row above ...
UPDATE `tests` SET `is_available` = 0 WHERE `userid` = :userid AND `testid` = :testid
而在去年,成立了一个cron求职
* * * * * [/path/to/php/]php /path/to/your/script/update.php
谢谢,让我检查所有这些信息,并开始了解CRON,因为我从来没有使用它,任何关于使用CRON的指南,你会推荐? – kastulo