Return to Snippet

Revision: 23174
at February 1, 2010 05:44 by ginoplusio


Initial Code
function fixTables($conn,$dbname) {
	// search for all the tables of
	// a db and run repair and optimize
	// note: this can take a lot of time
	// if you have big/many tables.
	global $conn;
	if ( $rs = $conn->query("SHOW TABLES FROM $dbname") ) {
		while ( $r = $rs->fetch_array() ) {
			$conn->query("REPAIR TABLE {$r[0]}");
			$conn->query("OPTIMIZE TABLE {$r[0]}");
		}
		$rs->free();
	}
}

Initial URL
http://www.barattalo.it/2010/01/29/10-php-usefull-functions-for-mysqli-improved-stuff/

Initial Description


Initial Title
MySQLi repair and optimize tables

Initial Tags
mysql, php, table

Initial Language
PHP