<?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]." "); $sql = "SHOW INDEX FROM ".$tables[$i]; $list = $dbi->fetchAll($sql); $indexs = array(); foreach($list as $item){ $indexs[$item['Key_name']][] = $item['Column_name']; } foreach($indexs as $key=>$val){ echo(" ".$key." ".implode(",",$val)." "); } } ?>