<?php
/*
SQL Buddy - Web based MySQL administration
http://www.sqlbuddy.com/
export.php
- export data in sql and csv formats
MIT license
2008 Calvin Lough <http://calv.in>
*/
include "functions.php";
loginCheck();
if ($_POST) {
$outputBuffer = "";
if (isset($db)) {
$dbs[] = $db;
if (isset($table))
$tables[] = $table;
else if (isset($_POST['EXPORTTABLE']))
$tables = $_POST['EXPORTTABLE'];
} else {
if (isset($_POST['EXPORTDB']))
$dbs = $_POST['EXPORTDB'];
$exportDb = true;
}
if (isset($_POST['FORMAT']))
$format = strtoupper($_POST['FORMAT']);
if (isset($_POST['STRUCTURE']))
$exportStructure = $_POST['STRUCTURE'];
if (isset($_POST['DATA']))
$exportData = $_POST['DATA'];
if (isset($_POST['DELIMITER']))
$delimiter = $_POST['DELIMITER'];
if (isset($_POST['FIELDNAMES']))
$printFieldnames = $_POST['FIELDNAMES'];
if (isset($_POST['INSERTTYPE']))
$insertType = $_POST['INSERTTYPE'];
if (isset($_POST['OUTPUT']))
$output = $_POST['OUTPUT'];
if (isset($_POST['OUTPUTFILETEXT'])) {
$outputFile = "exports/" . basename($_POST['OUTPUTFILETEXT']);
}
if (!isset($delimiter) || $delimiter == "TAB")
$delimiter = "\t";
else if ($delimiter == "SEMICOLON")
$delimiter = ";";
else if ($delimiter == "SPACE")
$delimiter = " ";
else
$delimiter = ",";
// for the next three - it has to be one or the other
// this way, if we get fed garbage, just go with a default
if (!isset($format) || $format != "CSV")
$format = "SQL";
if (!isset($output) || $output != "FILE" || !isset($outputFile))
$output = "BROWSER";
if (!isset($insertType) || $insertType != "COMPLETE")
$insertType = "COMPACT";
if (isset($format) && $format == "SQL" && !isset($exportStructure) && !isset($exportData)) {
$error = __("You must export either structure, data, or both") . ".";
} else if (!isset($dbs)) {
$error = __("Please select the databases that you would like to export") . ".";
} else if (isset($db) && !isset($tables)) {
$error = __("Please select the tables that you would like to export") . ".";
} else {
if ($format == "SQL") {
$version = $conn->getVersion();
$outputBuffer .= "--\r\n";
if ($conn->getAdapter() == "mysql")
$outputBuffer .= "-- MySQL " . $version . "\r\n";
else if ($conn->getAdapter() == "sqlite")
$outputBuffer .= "-- SQLite " . $version . "\r\n";
$outputBuffer .= "-- " . date("r") . "\r\n";
$outputBuffer .= "--\r\n\r\n";
}
foreach ($dbs as $d) {
$conn->selectDB($d);
// this checks to see if we are exporting an entire db with all tables
if (isset($exportDb) && $exportDb == true) {
if ($format == "SQL") {
$outputBuffer .= "CREATE DATABASE `$d`";
if ($conn->hasCharsetSupport())
{
$currentChar = "";
$currentCharSql = $conn->query("SHOW VARIABLES LIKE 'character_set_database'");
if ($conn->isResultSet($currentCharSql)) {
$currentChar = $conn->result($currentCharSql, 0, "Value");
$outputBuffer .= " DEFAULT CHARSET " . $currentChar;
}
}
$outputBuffer .= ";\r\n\r\n";
$outputBuffer .= "USE `$d`;\r\n\r\n";
}
$tableSql = $conn->listTables();
$tables = "";
if ($conn->isResultSet($tableSql)) {
while ($tableRow = $conn->fetchArray($tableSql)) {
$tables[] = $tableRow[0];
}
}
}
foreach ($tables as $t) {
if ($format == "SQL") {
if ($conn->getAdapter() == "mysql")
$structureSQL = $conn->query("SHOW FULL FIELDS FROM `$t`");
else
$structureSQL = $conn->describeTable($t);
$tableEngine = "";
$tableCharset = "";
$autoIncrement = "";
if (isset($exportStructure)) {
if ($conn->isResultSet($structureSQL)) {
if ($conn->getAdapter() == "mysql") {
$outputBuffer .= "CREATE TABLE `$t` (";
$infoSql = $conn->query("SHOW TABLE STATUS LIKE '$t'");
if ($conn->isResultSet($infoSql) == 1) {
$infoRow = $conn->fetchAssoc($infoSql);
$tableEngine = (array_key_exists("Type", $infoRow)) ? $infoRow['Type'] : $infoRow['Engine'];
if (array_key_exists('Collation', $infoRow) && isset($collationList)) {
$tableCharset = $collationList[$infoRow['Collation']];
}
if (array_key_exists('Auto_increment', $infoRow))
{
$autoIncrement = $infoRow['Auto_increment'];
}
}
} else if ($conn->getAdapter() == "sqlite") {
$outputBuffer .= "CREATE TABLE '$t' (";
}
$first = true;
if ($conn->getAdapter() == "mysql") {
while ($structureRow = $conn->fetchassoc($structureSQL)) {
if (!$first)
$outputBuffer .= ",";
$outputBuffer .= "\r\n `" . $structureRow['Field'] . "` " . $structureRow['Type'];
if (isset($collationList) && isset($structureRow['Collation']) && $structureRow['Collation'] != "NULL" && !is_null($structureRow['Collation'])) {
if ($collationList[$structureRow['Collation']] != $tableCharset) {
$outputBuffer .= " CHARSET " . $collationList[$structureRow['Collation']];
}
}
if (isset($structureRow['Null']) && $structureRow['Null'] != "YES")
$outputBuffer .= " not null";
if (isset($structureRow['Default']) && $structureRow['Default'] == "CURRENT_TIMESTAMP") {
$outputBuffer .= " default CURRENT_TIMESTAMP";
} else if (isset($structureRow['Default']) && $structureRow['Default'] != "") {
$outputBuffer .= " default '" . $structureRow['Default'] . "'";
}
if (isset($structureRow['Extra']) && $structureRow['Extra'] != "")
$outputBuffer .= " " . $structureRow['Extra'];
$first = false;
}
} else if ($conn->getAdapter() == "sqlite") {
foreach ($structureSQL as $structureRow) {
if (!$first)
$outputBuffer .= ",";
$outputBuffer .= "\r\n " . $structureRow[0] . " " . $structureRow[1];
$first = false;
}
}
// dont forget about the keys
if ($conn->getAdapter() == "mysql") {
$keySQL = $conn->query("SHOW INDEX FROM `$t`");
if ($conn->isResultSet($keySQL)) {
$currentKey = "";
while ($keyRow = $conn->fetchAssoc($keySQL)) {
// if this is the start of a key
if ($keyRow['Key_name'] != $currentKey) {
// finish off the last key first, if necessary
if ($currentKey != "")
$outputBuffer .= ")";
if ($keyRow['Key_name'] == "PRIMARY")
$outputBuffer .= ",\r\n PRIMARY KEY (";
elseif ($keyRow['Non_unique'] == "0")
$outputBuffer .= ",\r\n UNIQUE KEY (";
else
$outputBuffer .= ",\r\n KEY `" . $keyRow['Key_name'] . "` (";
$outputBuffer .= "`" . $keyRow['Column_name'] . "`";
} else {
$outputBuffer .= ",`" . $keyRow['Column_name'] . "`";
}
$currentKey = $keyRow['Key_name'];
}
if (isset($currentKey) && $currentKey != "")
$outputBuffer .= ")";
}
}
$outputBuffer .= "\r\n)";
if ($conn->getAdapter() == "mysql") {
if ($tableEngine) {
$outputBuffer .= ' ENGINE=' . $tableEngine;
}
if ($tableCharset) {
$outputBuffer .= ' DEFAULT CHARSET=' . $tableCharset;
}
if ($autoIncrement)
{
$outputBuffer .= ' AUTO_INCREMENT=' . $autoIncrement;
}
}
$outputBuf
没有合适的资源?快使用搜索试试~ 我知道了~
基于PHP的mysql在线管理程序SQL Buddy 多国语版.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共116个文件
pot:38个
png:32个
php:30个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 70 浏览量
2023-07-22
00:06:31
上传
评论
收藏 326KB ZIP 举报
温馨提示
基于PHP的mysql在线管理程序SQL Buddy 多国语版.zip
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 116 条
- 1
- 2
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/ff1da12a7f324b6098abfc954947719c_weixin_39827856.jpg!1)
助力毕业
- 粉丝: 2182
- 资源: 5146
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)