I have a users array that looks like:
array(1 => 10, 2 => 11 ...and so on for 100k+ values);
I am currently looping through each user to update the db row. It's very slow, ~ 30 seconds.
foreach ($users as $user_id => $plan_length) {
mysql_query("UPDATE users SET plan_length = $plan_length WHERE id = $user_id");
}
Is there a way to combine this into 1 query?
Ps.: I am aware of PDO guys, but I am focusing on the query itself here. No PDO for this client's project.
Ps. 2: If a solution is possible with PDO, we'll use PDO.
Ps. 3: The value of plan_length is number of months a user has been on a plan, which currently the maximum value is 20.