Splitting Big mysql queries in PHP


/ Published in: MySQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. while (1) {
  2. mysql_query("DELETE FROM logs WHERE log_date <= '2009-10-01' LIMIT 10000");
  3. if (mysql_affected_rows() == 0) {
  4. // done deleting
  5. break;
  6. }
  7. // you can even pause a bit
  8. usleep(50000);
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.