标签:dbi val exe show drop 利用 127.0.0.1 管理 lis
<?php $dbi = new DbMysql; $dbi->dbh = ‘mysql://root:mysql@127.0.0.1/coffeetest‘; $map = array(); $dbi->fetchMap("SHOW TABLES", $map); $tables = array_keys($map); for($i=0; $i<count($tables); $i++){ echo($tables[$i]."\n"); $sql = "SHOW INDEX FROM ".$tables[$i]; $list = $dbi->fetchAll($sql); $indexs = array(); foreach($list as $item){ $indexs[$item[‘Key_name‘]][] = $item[‘Column_name‘]; } $j = 0; $list = array(); foreach($indexs as $key=>$val){ $list[] = array(‘j‘=>$j, ‘key‘=>$key, ‘val‘=>implode(",",$val)); $j++; } $count = count($list) - 1; for($j=$count; $j>=0; $j=$j-1){ $me = $list[$j]; foreach($list as $item){ if($item[‘j‘]<$me[‘j‘] && $item[‘val‘]==$me[‘val‘]){ echo("\t".$j."\t".$me[‘key‘]."\t".$me[‘val‘]."\n"); $sql = "ALTER TABLE ".$tables[$i]." DROP INDEX `".$me[‘key‘]."`"; $dbi->execute($sql); } } } } ?>
标签:dbi val exe show drop 利用 127.0.0.1 管理 lis
原文地址:https://www.cnblogs.com/coffee_cn/p/8994334.html