PHP ActiveRecord批量删除未激活的帐户

PHP ActiveRecord批量删除未激活的帐户,php,sql,activerecord,batch-file,activation,Php,Sql,Activerecord,Batch File,Activation,我的网站使用php activerecord来处理sql 数据库中有三个字段: 连接日期、状态、激活代码 所有注册会员必须在24小时内激活,否则帐户将被删除 如何编写php代码来实现此功能? joindate现在使用php日期'Y-m-d'。 此外,代码可以自动工作,而无需手动启动为了获得准确的24小时停用,您需要将joindate sql字段更改为datetime,该字段也将保存时间。然后使用以下代码: // In the following statement, $JoinDate hold

我的网站使用php activerecord来处理sql 数据库中有三个字段: 连接日期、状态、激活代码

所有注册会员必须在24小时内激活,否则帐户将被删除

如何编写php代码来实现此功能? joindate现在使用php日期'Y-m-d'。
此外,代码可以自动工作,而无需手动启动

为了获得准确的24小时停用,您需要将joindate sql字段更改为datetime,该字段也将保存时间。然后使用以下代码:

// In the following statement, $JoinDate holds the sql `joindate` field
$timeDiff = time() - strtotime($JoinDate);

if($timDiff/3600 > 24) {
    // code to be executed if it's past the 24 hrs period
}

如何使功能自动启动?自动启动是指自动执行?如果是这样,PHP没有任何调度功能。您可以在每次加载页面时运行脚本,也可以使用Cron,它允许您按时间间隔运行脚本;