我需要通过更改注释的状态(将读取和读取/写入禁用)来更新 50K 记录,并希望确保我的 SQL 语句是正确的:
$query = "UPDATE node.nid AS nid, node.comment AS node_comment, node.type AS node_type
SET node.comment = '0'
WHERE (node.type in ('article', 'blog', 'event'))
AND (node.comment in ('1','2'))";
$total = 0;
$count = 0;
while ($query_result = db_query($query)){
$count++;
$total++;
if($count>200){
$count = 0;
sleep(300);
}
}
echo "Updated records:" . $total;
我在那里添加了一个定期暂停,因此它不会杀死服务器。这看起来好吗?