Detailed explanation of the steps to generate data dictionary in PHP

php中世界最好的语言
Release: 2023-03-28 09:28:01
Original
2427 people have browsed it

This time I will bring you a detailed explanation of the steps to generate a data dictionary in PHP. What are the precautions for generating a data dictionary in PHP? Here is a practical case, let's take a look.

I’m pressed for time recently, and I don’t have time to post a blog. I’d like to take advantage of the time now to share a knowledge point with you. When we are doing development, we may often encounter the problem of analyzing the database and making a data dictionary. Now the benefit is here. You only need to follow the link I sent to easily help you design the data dictionary. You don’t need to download the data dictionary tool. As a developer, you should be able to get this knowledge with just a few lines of code. So I won’t go into nonsense now. Look at the code below. You only need to change your database account and Just enter the password and run it.

Effect display:

After talking so much nonsense, I finally started writing code:

$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 = ''; //循环所有表 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']. '
字段名数据类型默认值 允许非空 自动递增备注
' . $f['COLUMN_NAME'] . '' . $f['COLUMN_TYPE'] . ' ' . $f['COLUMN_DEFAULT'] . ' ' . $f['IS_NULLABLE'] . '' . ($f['EXTRA']=='auto_increment'?'是':' ') . ' ' . $f['COLUMN_COMMENT'] . '

'; } //输出 echo ' '.$title.'
'; echo '

'.$title.'

'; echo $html; echo ''; ?>
Copy after login

I believe you will read the case in this article You have mastered the method. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to implement ADODB transaction processing in PHP

How to use Thinkphp5 uploadify to implement file upload

The above is the detailed content of Detailed explanation of the steps to generate data dictionary in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!