mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-01-03 18:38:12 +00:00
数据库备份
This commit is contained in:
parent
6925c55bea
commit
612719ffaf
119
public/mysql.php
119
public/mysql.php
@ -1,9 +1,10 @@
|
||||
<?
|
||||
// | CRMEB
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | zbMysql
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2012-2016 http://www.xazbkj.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: honor <rongyao_xu@163.com>
|
||||
// | Author: honor <sugar1569@vip.qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
//访问方法 /mysql.php?pwd=******&table=表名为空所有表
|
||||
session_start();
|
||||
@ -16,9 +17,9 @@ header("Content-type:text/html;charset=utf-8");
|
||||
$database = array();
|
||||
$password = '327677';//访问密码GET['pwd'] 传输
|
||||
$database['DB_HOST'] = '127.0.0.1';
|
||||
$database['DB_NAME'] = '';//数据库名称
|
||||
$database['DB_USER'] = '';//用户名
|
||||
$database['DB_PWD'] = '';//密码
|
||||
$database['DB_NAME'] = 'gitcrmeb';//数据库名称
|
||||
$database['DB_USER'] = 'gitcrmeb';//用户名
|
||||
$database['DB_PWD'] = 'y3NfiJTjRp8PNeee';//密码
|
||||
$char_set = 'UTF8';//数据库编码
|
||||
date_default_timezone_set('Asia/Shanghai');
|
||||
$mysql_conn = @mysqli_connect("{$database['DB_HOST']}", "{$database['DB_USER']}", "{$database['DB_PWD']}") or die("Mysql connect is error.");
|
||||
@ -32,37 +33,37 @@ $_SESSION['pwd'] = $pwd;
|
||||
|
||||
if($_GET['table'])
|
||||
{
|
||||
$tables[]['TABLE_NAME'] = $_GET['table'];
|
||||
$tables[]['TABLE_NAME'] = $_GET['table'];
|
||||
}else{
|
||||
// 取得所有表名
|
||||
while ($row = mysqli_fetch_array($result))
|
||||
{
|
||||
$tables[]['TABLE_NAME'] = $row[0];
|
||||
}
|
||||
// 取得所有表名
|
||||
while ($row = mysqli_fetch_array($result))
|
||||
{
|
||||
$tables[]['TABLE_NAME'] = $row[0];
|
||||
}
|
||||
}
|
||||
// 循环取得所有表的备注及表中列消息
|
||||
foreach($tables as $k => $v)
|
||||
{
|
||||
$sql = 'SELECT * FROM ';
|
||||
$sql .= 'INFORMATION_SCHEMA.TABLES ';
|
||||
$sql .= 'WHERE ';
|
||||
$sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '{$database['DB_NAME']}'";
|
||||
$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['DB_NAME']}'";
|
||||
$fields = array();
|
||||
$field_result = mysqli_query($mysql_conn,$sql);
|
||||
while ($t = mysqli_fetch_array($field_result))
|
||||
{
|
||||
$fields[] = $t;
|
||||
}
|
||||
$tables[$k]['COLUMN'] = $fields;
|
||||
$sql = 'SELECT * FROM ';
|
||||
$sql .= 'INFORMATION_SCHEMA.TABLES ';
|
||||
$sql .= 'WHERE ';
|
||||
$sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '{$database['DB_NAME']}'";
|
||||
$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['DB_NAME']}'";
|
||||
$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);
|
||||
//print_r($tables);
|
||||
@ -71,38 +72,38 @@ if(isset($_GET['table']))
|
||||
{
|
||||
$html .= '<h1 style="text-align:center;">表结构</h1>';
|
||||
$html .= '<p style="text-align:center;margin:20px auto;">生成时间:' . date('Y-m-d H:i:s') . '</p>';
|
||||
// 循环所有表
|
||||
foreach($tables as $k => $v)
|
||||
{
|
||||
$html .= '<table border="1" cellspacing="0" cellpadding="0" align="center">';
|
||||
$html .= '<caption>表名:' . $v['TABLE_NAME'] . ' ------- ' . $v['TABLE_COMMENT'] . '</caption>';
|
||||
$html .= '<tbody><tr><th>字段名</th><th>数据类型</th><th>默认值</th><th>允许非空</th><th>自动递增</th><th>备注</th></tr>';
|
||||
$html .= '';
|
||||
foreach($v['COLUMN'] AS $f)
|
||||
{
|
||||
$html .= '<td class="c1">' . $f['COLUMN_NAME'] . '</td>';
|
||||
$html .= '<td class="c2">' . $f['COLUMN_TYPE'] . '</td>';
|
||||
$html .= '<td class="c3">' . $f['COLUMN_DEFAULT'] . '</td>';
|
||||
$html .= '<td class="c4">' . $f['IS_NULLABLE'] . '</td>';
|
||||
$html .= '<td class="c5">' . ($f['EXTRA'] == 'auto_increment'?'是':' ') . '</td>';
|
||||
$html .= '<td class="c6">' . $f['COLUMN_COMMENT'] . '</td>';
|
||||
$html .= '</tr>';
|
||||
}
|
||||
$html .= '</tbody></table></p>';
|
||||
// 循环所有表
|
||||
foreach($tables as $k => $v)
|
||||
{
|
||||
$html .= '<table border="1" cellspacing="0" cellpadding="0" align="center">';
|
||||
$html .= '<caption>表名:' . $v['TABLE_NAME'] . ' ------- ' . $v['TABLE_COMMENT'] . '</caption>';
|
||||
$html .= '<tbody><tr><th>字段名</th><th>数据类型</th><th>默认值</th><th>允许非空</th><th>自动递增</th><th>备注</th></tr>';
|
||||
$html .= '';
|
||||
foreach($v['COLUMN'] AS $f)
|
||||
{
|
||||
$html .= '<td class="c1">' . $f['COLUMN_NAME'] . '</td>';
|
||||
$html .= '<td class="c2">' . $f['COLUMN_TYPE'] . '</td>';
|
||||
$html .= '<td class="c3">' . $f['COLUMN_DEFAULT'] . '</td>';
|
||||
$html .= '<td class="c4">' . $f['IS_NULLABLE'] . '</td>';
|
||||
$html .= '<td class="c5">' . ($f['EXTRA'] == 'auto_increment'?'是':' ') . '</td>';
|
||||
$html .= '<td class="c6">' . $f['COLUMN_COMMENT'] . '</td>';
|
||||
$html .= '</tr>';
|
||||
}
|
||||
$html .= '</tbody></table></p>';
|
||||
$html .= '<p style="text-align:left;margin:20px auto;">总共:' . count($v['COLUMN']) . '个字段</p>';
|
||||
$html .= '</body></html>';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$html .= '<h1 style="text-align:center;">数据字典</h1>';
|
||||
$html .= '<p style="text-align:center;margin:20px auto;">生成时间:' . date('Y-m-d H:i:s') . '</p>';
|
||||
foreach($tables as $k => $v)
|
||||
{
|
||||
$html .= '<table border="1" cellspacing="0" cellpadding="0" align="center">';
|
||||
$html .= '<caption>表名:' . $v['TABLE_NAME'] . ' ------- ' . $v['TABLE_COMMENT'] . '<a href="javascript:void(0)" class="abiao" data-tabname="'.$v['TABLE_NAME'].'" >[查看结构]</a></caption>';
|
||||
|
||||
|
||||
$html .= '</tbody></table></p>';
|
||||
}
|
||||
foreach($tables as $k => $v)
|
||||
{
|
||||
$html .= '<table border="1" cellspacing="0" cellpadding="0" align="center">';
|
||||
$html .= '<caption>表名:' . $v['TABLE_NAME'] . ' ------- ' . $v['TABLE_COMMENT'] . '<a href="javascript:void(0)" class="abiao" data-tabname="'.$v['TABLE_NAME'].'" >[查看结构]</a></caption>';
|
||||
|
||||
|
||||
$html .= '</tbody></table></p>';
|
||||
}
|
||||
$html .= '<p style="text-align:left;margin:20px auto;">总共:' . count($tables) . '个数据表</p>';
|
||||
$html .= '</body></html>';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user