PHP implementation Generate data Dictionary function example

Source: Internet
Author: User
Tags mysql connect
This article mainly introduces the PHP implementation to generate data dictionary functions, including PHP for MySQL common connection, data table query, traversal, table Form composition and other related operations skills, the need for friends can refer to the following

This article describes the PHP implementation generated data dictionary functionality. Share to everyone for your reference, as follows:

Recent time is urgent, there is no time to blog, while now a bit of time to share a knowledge point. When we do the development, perhaps often encountered on the database analysis, to do a data dictionary, then now the benefits come, everyone just need to focus on the link I sent to help you to solve the data dictionary design, no longer do you download data dictionary that tool, as a developer, Just a few lines of code should be able to take care of this knowledge, then now nonsense I don't say more, we look at the code below, we just need to change your database account and password and then run it.

Effect Show:

Having said so much nonsense, I finally began to write the code:

<?php/*** generate MySQL data dictionary *///config database $dbserver = "127.0.0.1"; $dbusername = "Account"; $dbpassword = "password"; $database = "database";//Other configuration $title = ' 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 through all table notes and column messages in the table 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>

Articles you may be interested in:

CodeIgniter Framework Database Basic operation of the relevant explanation

PHP Get all dates for this week or the last seven days all dates method

Comparison of the effects of PHP lcg_value and Mt_rand on generating 0~1 random decimals

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.