coffee_cn

博客园 首页 新随笔 联系 订阅 管理
<?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'];
    }
    foreach($indexs as $key=>$val){
        echo("\t".$key."\t".implode(",",$val)."\n");
    }
}
?>

 

posted on 2018-05-05 12:16  coffee  阅读(190)  评论(0编辑  收藏  举报