lists_to_list_hot.php 837 字节
<?php

include_once "../vendor/autoload.php";

/**
 * 把lists表的is_hots字段为1的记录插入到list_hot表中 并删除list表中的这些记录
 */

// 一个月以前的数据
$one_month_ago = strtotime(date('Y-m-d', strtotime('-1 month')));

// 查询lists lists_hot
$id = 389884523;
while (true){
    $data = db()->first("select * from lists where  id > {$id} and `is_hots` = 1 and `udate` < {$one_month_ago} limit 1;");
    if($data){
        $id = $data['id'];
        try {
            db()->throw()->insert('lists_hot', $data);
        } catch (\Exception $e) {
            @file_put_contents('lists_to_lists_hot.data.error.log', json_encode($data)."\n", FILE_APPEND);
        }
        db()->delete('lists', ['id' => $data['id']]);
        echo $id . " ok \n";
//        break;
    }else{
        sleep(5);
    }
}