Haunted Dawg Posted May 11, 2008 Share Posted May 11, 2008 Well, i was searching google for "mysql tips & tricks" and i found some nice & interesting stuff. Just add this code to any file you want to: <?php echo '<title>MySql Compilation</title>'; $c = mysql_connect('localhost','username','password') or die(mysql_error()); mysql_select_db('username_database',$c); echo 'MySql List Processes <textarea name="u" id="u" cols="40" rows="1" readonly>'; $resultado = mysql_list_processes($c); while ($fila = mysql_fetch_assoc($resultado)){ printf("%s %s %s %s %s\n", $fila["Id"], $fila["Host"], $fila["db"], $fila["Command"], $fila["Time"]); } mysql_free_result($resultado); echo '</textarea> MySql Server info, MySql Stats, MySql Host Info, MySql Client Info, MySql Proto Info <textarea name="i" id="i" cols="50" rows="10" readonly>'; $status = explode(' ', mysql_stat($c)); print_r($status); print_r("MySql Server Info: ".mysql_get_server_info()."\n"); print_r("MySql Host Info: ".mysql_get_host_info()."\n"); print_r("MySql Client Info: ".mysql_get_client_info()."\n"); print_r("MySql Proto Info: ".mysql_get_proto_info()."\n"); echo '</textarea> Show Columns From Specific Table <textarea cols="50" rows="10" name="p" id="p" readonly>'; $result = mysql_query("SHOW COLUMNS FROM users"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { print_r($row); } } echo '</textarea> MySql List DB\'s <textarea cols="20" rows="5" name="t" id="t" readonly>'; $db_list = mysql_list_dbs($c); $d = "\n"; while ($row = mysql_fetch_object($db_list)) { echo $row->Database . $d; } echo '</textarea> MySql Show Tables <textarea cols="50" rows="20" name="p" id="p" readonly>'; $all_tables = mysql_query("SHOW TABLES") or die(mysql_error()); $d = "\n"; while ($soc = mysql_fetch_assoc($all_tables)) { foreach($soc as $db => $tablename) { echo $tablename. $d; } } echo '</textarea>'; ?> Some bits & peaces i made my self like the list all tables but thats pretty easy :) Hope you enjoy, and befor posting some thing please think about what your posting :) Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted May 11, 2008 Author Share Posted May 11, 2008 Re: MySql Compilation While i was searching around i also found this cool script i dont know what it does and too scared to try it on my game. Maybe some one can explain more what this script does: <?php $c = mysql_connect('localhost','username','password') or die(mysql_error()); mysql_select_db('username_database',$c); $alltables = mysql_query("SHOW TABLES"); while ($table = mysql_fetch_assoc($alltables)) { foreach ($table as $db => $tablename) { mysql_query("OPTIMIZE TABLE '".$tablename."'") or die(mysql_error()); } } ?> Quote Link to comment Share on other sites More sharing options...
Will Posted May 11, 2008 Share Posted May 11, 2008 Re: MySql Compilation Just optimizes the tables: OPTIMIZE TABLE http://dev.mysql.com/doc/refman/5.0/en/optimize-table.html Quote Link to comment Share on other sites More sharing options...
topmorpg Posted May 11, 2008 Share Posted May 11, 2008 Re: MySql Compilation While i was searching around i also found this cool script i dont know what it does and too scared to try it on my game. Maybe some one can explain more what this script does: <?php $c = mysql_connect('localhost','username','password') or die(mysql_error()); mysql_select_db('username_database',$c); $alltables = mysql_query("SHOW TABLES"); while ($table = mysql_fetch_assoc($alltables)) { foreach ($table as $db => $tablename) { mysql_query("OPTIMIZE TABLE '".$tablename."'") or die(mysql_error()); } } ?> I currently use something similar I built. It will grab all tables and make sure they are optimized Much like if you go into phpmyadmin select all. and optimize them. TJ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.