note 57483 deleted from control-structures.foreach by felipe

From: Date: Tue, 29 Jan 2008 11:24:22 +0000
Subject: note 57483 deleted from control-structures.foreach by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135522@lists.php.net to get a copy of this message
Note Submitter: retula AT gmail DOT com ---- Here is a cool script to optimize all the tables in a database! (mysql only) <?php // connect to the db mysql_connect("host","username","pw"); mysql_select_db("database"); //get all tables $alletabellen = mysql_query("SHOW TABLES"); //go trough them, save as an array while($tabel = mysql_fetch_assoc($alletabellen)){ //go through the array ( $db => $tabelnaam ) foreach ($tabel as $db => $tabelnaam) { //optimize every table mysql_query("OPTIMIZE TABLE ".$tabelnaam."") or die(mysql_error()); } } ?> Enjoy!

« previous php.notes (#135522) next »