Commit 8b42dba8fa265cd6ab95d2fc55e9e962d127bb29
1 parent
383fc857
KTC-239
"CLONE -Performance has become tragically slow (SUP-443)" Added. Implemented a a command line script to do basic mysql optmisation on tables. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7292 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
52 additions
and
0 deletions
bin/dbmaint.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once('../config/dmsDefaults.php'); | |
| 4 | + | |
| 5 | +print _kt('DB Maintenance') . "...\n\n"; | |
| 6 | + | |
| 7 | +$action = 'check'; | |
| 8 | +$sqlaction = 'check table'; | |
| 9 | +if ($argc > 0) | |
| 10 | +{ | |
| 11 | + foreach($argv as $arg) | |
| 12 | + { | |
| 13 | + $arg=strtolower($arg); | |
| 14 | + switch ($arg) | |
| 15 | + { | |
| 16 | + case 'check': | |
| 17 | + case 'repair': | |
| 18 | + case 'optimize': | |
| 19 | + $sqlaction="$arg table"; | |
| 20 | + $action = $arg; | |
| 21 | + break; | |
| 22 | + case 'help': | |
| 23 | + print "Usage: dbmaint.php repair|check|optimize\n"; | |
| 24 | + exit; | |
| 25 | + } | |
| 26 | + } | |
| 27 | +} | |
| 28 | + | |
| 29 | +print '* ' . sprintf(_kt("Action selected: %s"), $action) . "\n\n"; | |
| 30 | + | |
| 31 | +$sql = "show tables"; | |
| 32 | +$tables = DBUtil::getResultArray($sql); | |
| 33 | +foreach($tables as $table) | |
| 34 | +{ | |
| 35 | + $key = array_keys($table); | |
| 36 | + | |
| 37 | + $tablename=$table[$key[0]]; | |
| 38 | + $sql = "$sqlaction $tablename"; | |
| 39 | + $result = DBUtil::getOneResult($sql); | |
| 40 | + | |
| 41 | + if (PEAR::isError($result)) | |
| 42 | + { | |
| 43 | + print sprintf(_kt("Attempted: %s"), $sql) . "\n"; | |
| 44 | + print sprintf(_kt(' *: %s'), $result->getMessage()) . "\n"; | |
| 45 | + continue; | |
| 46 | + } | |
| 47 | + print sprintf(_kt("Running: %s - %s"), $sql, $result['Msg_text']) . "\n"; | |
| 48 | +} | |
| 49 | + | |
| 50 | +print _kt('Done.') . "\n"; | |
| 51 | + | |
| 52 | +?> | |
| 0 | 53 | \ No newline at end of file | ... | ... |