0
我需要改變的評論的狀態來更新50K記錄(車削讀&讀取/寫入禁用),並希望確保我的SQL語句是正確的:更新SQL記錄在Drupal
$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;
我加在那裏定期暫停,所以它不會殺死服務器。這看起來好嗎?
我認爲備份數據庫並測試它可能是一個更好的主意。 –