PHP Generate MySQL data dictionary _php tutorial

Source: Internet
Author: User
Tags mysql connect
Sometimes we get other people's database, but there is no data dictionary, this PHP applet to help you easily solve.

Code is found on the web, of course, this code is only generated data dictionary, view, stored procedures and so on is wood.

 $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. = '

'. $v [' table_comment ']. '

'; $html. = ' '; $html. = ' '; $html. = ' '; $html. = '; foreach ($v [' COLUMN '] as $f) {$html. = ' '; $html. = ' '; $html. = ' '; $html. = ' '; $html. = ' '; $html. = ' '; $html. = ' '; } $html. = '
. $v [' table_name ']. ' '. $v [' table_comment ']. '
Field name Data Type Default Value allow non-null Auto Increment Notes
' . $f [' column_name ']. '' . $f [' Column_type ']. '' . $f [' Column_default ']. '' . $f [' is_nullable ']. '' . ($f [' EXTRA ']== ' auto_increment '? ' Is ': '). '' . $f [' column_comment ']. '

';} Output echo ' <title>'. $title. '</title>'; Echo '

'. $title. '

"Echo $html; echo."';? >


Results after the run:



http://www.bkjia.com/PHPjc/664292.html www.bkjia.com true http://www.bkjia.com/PHPjc/664292.html techarticle Sometimes we get other people's database, but there is no data dictionary, this PHP applet to help you easily solve. The code is found online, of course, this code is only generated data word ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.