<?php/** * Generate MySQL data dictionary * * @version $id $ * @author niming<[email protected]> *///metabase $dbserver = "Localho St "; $dbusername =" root "; $dbpassword =" root "; $database = ' mydb ';//other configuration $title = ' system data dictionary '; $mysql _conn = @mysql_connect (" $ DBServer "," $dbusername "," $dbpassword ") or Die (" Mysql Connect is error. "); mysql_select_db ($database, $mysql _conn); mysql_query (' SET NAMES utf8 ', $mysql _conn); $table _result = mysql_query (' Show Tables ', $mysql _conn);//Get all the table names while ($row = mysql_fetch_array ($table _result)) {$tables [] [' table_name '] = $row [0];} Loop get notes for all tables foreach ($tables as $k + = $v) {$sql = ' SELECT * from '; $sql. = ' Information_schema. TABLES '; $sql. = ' WHERE '; $sql. = "table_name = ' {$v [' table_name ']} ' and Table_schema = ' {$database} '"; $table _result = mysql_query ($sql, $mysql _conn); while ($t = mysql_fetch_array ($table _result)) {$tables [$k] [' table_comment '] = $t [' table_comment ']; } $sql = ' SELECT * from '; $sql. = ' Information_schema.COLUMNS '; $sql. = ' WHERE '; $sql. = "table_name = ' {$v [' table_name ']} ' and Table_schema = ' {$database} '"; $fields = Array (); $field _result = mysql_query ($sql, $mysql _conn); while ($t = mysql_fetch_array ($field _result)) {$fields [] = $t; } $tables [$k] [' COLUMN '] = $fields;} Mysql_close ($mysql _conn); $html = ";//Loop All tables foreach ($tables as $k = $v) {$html. = ' <p>
PHP Export Database Data dictionary script