数据字典自动生成

php升级7.0后,导致mysql使用mysql_connect无法连接数据库,原因是php5.5.0中已弃用,并在7.0中被删除。参考:http://php.net/manual/zh/mysqlinfo.api.choosing.php
以下数据字典生成兼容php7.0及以上版本:

 $v) {
  $sql = 'SELECT * FROM ';
  $sql .= 'INFORMATION_SCHEMA.TABLES ';
  $sql .= 'WHERE ';
  $sql .= "table_name = '{$v['TABLE_NAME']}'  AND table_schema = '{$database}'";
  $table_result = mysqli_query($mysql_conn, $sql);
  while ($t = mysqli_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 = mysqli_query($mysql_conn, $sql);
  while ($t = mysqli_fetch_array($field_result)) {
    $fields[] = $t;
  }
  $tables[$k]['COLUMN'] = $fields;
}
mysqli_close($mysql_conn);
$html = '';
//循环所有表
foreach ($tables as $k => $v) {
  if (!in_array($v['TABLE_NAME'], $no_show_table)) {
    $html .= '

' . ($k + 1) . '、' . $v['TABLE_COMMENT'] . ' (' . $v['TABLE_NAME'] . ')

'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; foreach ($v['COLUMN'] as $f) { if (!in_array($f['COLUMN_NAME'], $no_show_field)) { $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; } } $html .= ''; $html .= '
字段名数据类型默认值允许非空自动递增备注
' . $f['COLUMN_NAME'] . '' . $f['COLUMN_TYPE'] . '' . $f['COLUMN_DEFAULT'] . '' . $f['IS_NULLABLE'] . '' . ($f['EXTRA'] == 'auto_increment' ? '是' : ' ') . '' . $f['COLUMN_COMMENT'] . '
'; } } ?> 数据字典

数据字典自动生成

你可能感兴趣的:(数据字典自动生成)