我有大约 70 000 行的表。有 6000 行需要查找、更改和保存(我必须经常这样做,一周几次)。目前,我正在这样做,完成时间超过 2 分钟:(有什么建议吗?:()
$query = mysql_query("SELECT meta_value FROM my_table WHERE meta_key = 'key' AND meta_value LIKE '%something%'")or die(mysql_error());
$new = "soemthing something";
while($row = mysql_fetch_array($query)){
$old = unserialize($row['meta_value']);
$new_meta_r = str_replace($old['color'],$new,$old);
$new_meta = serialize($new_meta_r);
$update_meta = mysql_query("UPDATE my_table SET meta_value = '$new_meta' WHERE meta_key = 'key' AND meta_value LIKE '%something%'")or die(mysql_error());
}