I have 200,000 rows to update. From tests using its method it takes 7 minutes to update 1,000 rows, so it will take around 24 hours to complete :(.
Is there a faster way to do this in Codeigniter than the method I'm using?
for($c=1;$c<=200;$c++) {
$limit = 1000;
$offset = ($c*1000)-1000;
if($c==1) {
$query = $this->db->query("SELECT email,password,first_name,last_name FROM users WHERE email!='' ORDER BY id ASC LIMIT ".$limit);
} else {
$query = $this->db->query("SELECT email,password,first_name,last_name FROM users WHERE email!='' ORDER BY id ASC LIMIT ".$offset.",".$limit);
}
$appdb->trans_start();
foreach($query->result() as $row) {
$email = $row->email;
$password = $row->password;
$first_name = $row->first_name;
$last_name = $row->last_name;
$newpassword = password_hash($password, PASSWORD_DEFAULT);
$appdb->query("UPDATE users_user SET password='$newpassword',first_name='$first_name',last_name='$last_name' WHERE email='$email'");
}
$appdb->trans_complete();
}
The e-mail is unique, so I cannot use update_batch
.