1. 程式人生 > >利用PHP腳本輔助MySQL數據庫管理2-表主鍵表索引

利用PHP腳本輔助MySQL數據庫管理2-表主鍵表索引

dbi ble nbsp 管理 item tab count key root

<?php
$dbi = new DbMysql;
$dbi->dbh = ‘mysql://root:[email protected]/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"); } } ?>

利用PHP腳本輔助MySQL數據庫管理2-表主鍵表索引