Run REPAIR and OPTIMIZE on every table of your MYSQL DB


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



Copy this code and paste it in your HTML
  1. function fixTables($dbname) {
  2. // search for all the tables of
  3. // a db and run repair and optimize
  4. // note: this can take a lot of time
  5. // if you have big/many tables.
  6. $result = mysql_list_tables($dbname) or die(mysql_error());
  7. while ($row = mysql_fetch_row($result)) {
  8. mysql_query("REPAIR TABLE $row[0]");
  9. mysql_query("OPTIMIZE TABLE $row[0]");
  10. }
  11. }

URL: http://www.barattalo.it/2010/01/25/10-php-usefull-functions-for-mysql-stuff/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.