【问题标题】:PHP ActiveRecord batch delete inactivated accountPHP ActiveRecord 批量删除未激活账户
【发布时间】:2012-12-04 19:13:41
【问题描述】:

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

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

如何编写php代码来实现这个功能? joindate 现在使用 php date('Y-m-d')。 代码也可以自动工作而无需手动启动

【问题讨论】:

    标签: php sql activerecord batch-file activation


    【解决方案1】:

    为了获得准确的 24 小时停用,您需要将joindate sql 字段更改为输入“日期时间”,该字段也将保留时间。然后使用此代码:

    // 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,它允许您按时间间隔运行脚本。
    • 我的加入日期正在使用 php date('Y-m-d');
    猜你喜欢
    • 2015-12-26
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2015-12-13
    • 2014-11-29
    • 2018-04-07
    • 1970-01-01
    相关资源
    最近更新 更多