获取mysql的表注释和字段注释
表注释在
库的 TABLES 表中TABLE_COMMENT 字段里或者使用:
show table status
最后一列:Comment 就是表注释
取一个表里面的字段注释的sql:
show full fields from table
最后一列:Comment 就是字段注释
<?php /* * 数据库字典 适用所有数据库 */ $web_title = "数据库结构"; include(__DIR__."/xiang_s.php"); // 权限判断文件 if($user_data["type"]==0){ $sql = "show table status"; $mysqli_data = $xiang->xiang_data($sql); $array = array("Field","Type","Collation","Null","Key","Default","Extra","Privileges","Comment"); $array = array("字段","字段类型","排序规则","是否为空","索引","默认值","额外","特殊权限","注释"); foreach ($array as $tab_bb) { $tab_b = $tab_b == null ? "<th>".$tab_bb."</th>" : $tab_b."<th>".$tab_bb."</th>"; } foreach ($mysqli_data as $v) { foreach ($v as $k=>$va) { $$k = $va; $xiang_eee = null; $sql_fields = "show full fields from $Name"; $fields_data = $xiang->xiang_data($sql_fields); foreach ($fields_data as $vab) { $tab_d = null; $tab_cc = null; foreach ($vab as $value) { $tab_cc = $tab_cc."<td>".$value."</td>"; } $tab_d = '<tr>'.$tab_cc.'</tr>'; $xiang_eee = $xiang_eee.$tab_d; } $xiang_fff = $xiang_eee; $xiang_ddd = $xiang_fff; } $xiang_ccc = '<div class="layui-form"><table class="layui-table"><thead><tr>'.$tab_b.'</tr></thead><tbody>'.$xiang_ddd.'</tbody> </table></div>'; $xiang_bbb = $xiang_bbb.'<div class="layui-colla-item"><h2 class="layui-colla-title">'.$Name.' '.$Comment.'</h2><div class="layui-colla-content layui-show">'.$xiang_ccc.'</div></div>'; } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>平台数据库字典</title> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all"> <link rel="stylesheet" href="../css/public.css" media="all"> <style> .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;} </style> </head> <body> <div class="layuimini-container"> <div class="layuimini-main"> <div style="padding: 0 0 10px 0;background-color: #ffffff;"> <div class="layui-row layui-col-space15"> <div class="layui-col-md12"> <div class="layui-card"> <div class="layui-card-header" style="display:none;">本平台数据库字典完整版</div> <div class="layui-card-body"> 包含平台数据库所有表与表里全部字段的信息 </div> </div> </div> </div> </div> <div class="layui-collapse" lay-filter="xiang_mysql"> <?php echo $xiang_bbb;?> </div> </div> </div> <script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script> <script> layui.use(['form','element'], function () { var element = layui.element; var form = layui.form , layer = layui.layer; //监听折叠 element.on('collapse(xiang_mysql)', function(data){ //layer.msg('展开状态:'+ data.show); }); }); </script> </body> </html>