Posted By

ginoplusio on 01/25/10


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

ginoplusio
pablo808


Run REPAIR and OPTIMIZE on every table of your MYSQL DB


 / Published in: PHP
 

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

  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. }

Report this snippet  

You need to login to post a comment.