无为清净楼资源网 Design By www.qnjia.com
把mysql数据库生成数据字典,直接可用便于查看数据库表、字段,做一个数据字典是很有必要的,下面只需要简单更改下配置就可以用了,样式也是挺好的。
<"SHOW TABLE STATUS FROM " . DB_NAME; $result=mysql_query($sql); $array=array(); while($rows=mysql_fetch_assoc($result)){ $array[]=$rows; } // table count $tab_count = count($array); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="zh"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>'.APPNAME.'--数据字典</title> <style type="text/css"> table caption, table th, table td { padding: 0.1em 0.5em 0.1em 0.5em; margin: 0.1em; vertical-align: top; } th { font-weight: bold; color: black; background: #D3DCE3; } table tr.odd th, .odd { background: #E5E5E5; } table tr.even th, .even { background: #f3f3f3; } .db_table{ border-top:1px solid #333; } .title{font-weight:bold;} </style> </head> <body> <div style="text-align:center;background:#D3DCE3;font-size:19px;"> <b>'.APPNAME.'--数据字典</b> </div> <div style="background:#f3f3f3;text-align:center;">(注:共'.$tab_count.'张表,按ctrl+F查找关键字)</div>'."\n"; for($i=0;$i<$tab_count;$i++){ echo '<ul type="square">'."\n"; echo ' <li class="title">'; echo ($i+1).'、表名:[' . $array[$i]['Name'] . '] 注释:' . $array[$i]['Comment']; echo '</li>'."\n"; //查询数据库字段信息 $tab_name = $array[$i]['Name']; $sql_tab='show full fields from `' . $array[$i]['Name'].'`'; $tab_result=mysql_query($sql_tab); $tab_array=array(); while($r=mysql_fetch_assoc($tab_result)){ $tab_array[]=$r; } //show keys $keys_result=mysql_query("show keys from `".$array[$i]['Name'].'`',$conn); $arr_keys=mysql_fetch_array($keys_result); echo '<li style="list-style: none outside none;"><table border="0" class="db_table" >'; echo '<tr class="head"> <th style="width:110px">字段</th> <th>类型</th> <th>为空</th> <th>额外</th> <th>默认</th> <th style="width:95px">整理</th> <th>备注</th></tr>'; for($j=0;$j<count($tab_array);$j++){ $key_name=$arr_keys['Key_name']; if($key_name="PRIMARY"){ $key_name='主键('.$key_name.')'; } $key_field=$arr_keys['Column_name']; if ( $tab_array[$j]['Field']==$key_field){ $key_value="PK"; }else{ $key_value=""; } echo ' <tr class="'.($j%2==0"odd":"even").'">'."\n"; echo ' <td>' . $tab_array[$j]['Field'] . '</td>'."\n"; echo ' <td>' . $tab_array[$j]['Type'] . '</td>'."\n"; echo ' <td>' . ($key_value!=''"\n"; echo ' <td>' . $tab_array[$j]['Extra'] . '</td>'."\n"; echo ' <td>' . $tab_array[$j]['Default'] . '</td>'."\n"; echo ' <td>' . $tab_array[$j]['Collation'] . '</td>'."\n"; echo ' <td>' . ($key_value!=''"\n"; echo ' </tr>'."\n"; } echo ' </table></li>'."\n"; echo '</ul>'."\n"; } echo '</body>'."\n"; echo '</html>'."\n";
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
标签:
php,mysql,数据字典
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年10月04日
2024年10月04日
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]
- 班得瑞原装进口《第九张新世纪专辑:微风山谷》1CD[APE/CUE分轨][331MB]
- 陈慧琳.2008-Love.Fighters演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 米志宏.1994-HAPPY1994【波丽佳音】【WAV+CUE】
- 潘美辰.2006-最冷的夏天(引进版)【美梦辰真】【WAV+CUE】
- 班得瑞原装进口《第十张新世纪专辑:月光水岸》1CD[APE/CUE分轨][277.2MB]
- 班得瑞原装进口《第十一张新世纪专辑:雾色山脉》1CD[APE/CUE分轨][291.6MB]