Convert end of line chars we get from MySQL (bug #1042521).

This commit is contained in:
Michal Čihař
2004-10-11 12:18:03 +00:00
parent fc085a6b91
commit 620f9b764b
2 changed files with 13 additions and 6 deletions

View File

@@ -12,6 +12,8 @@ $Source$
2004-10-11 Michal Čihař <michal@cihar.com> 2004-10-11 Michal Čihař <michal@cihar.com>
* tbl_query_box.php: Don't try to replace %t and %f when table name is empty. * tbl_query_box.php: Don't try to replace %t and %f when table name is empty.
* libraries/export/sql.php: Convert end of line chars we get from MySQL
(bug #1042521).
2004-10-08 Garvin Hicking <pma@supergarv.de> 2004-10-08 Garvin Hicking <pma@supergarv.de>
* lots of files: Adjusted superfluous spaces, added * lots of files: Adjusted superfluous spaces, added

View File

@@ -221,6 +221,15 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
$create_query = $row[1]; $create_query = $row[1];
unset($row); unset($row);
// Convert end of line chars to one that we want (note that MySQL doesn't return query it will accept in all cases)
if (strpos($create_query, "(\r\n ")) {
$create_query = str_replace("\r\n", $crlf, $create_query);
} elseif (strpos($create_query, "(\n ")) {
$create_query = str_replace("\n", $crlf, $create_query);
} elseif (strpos($create_query, "(\r ")) {
$create_query = str_replace("\r", $crlf, $create_query);
}
// Should we use IF NOT EXISTS? // Should we use IF NOT EXISTS?
if (isset($GLOBALS['if_not_exists'])) { if (isset($GLOBALS['if_not_exists'])) {
$create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query); $create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query);
@@ -229,12 +238,8 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
// are there any constraints to cut out? // are there any constraints to cut out?
if (preg_match('@CONSTRAINT|FOREIGN[\s]+KEY@', $create_query)) { if (preg_match('@CONSTRAINT|FOREIGN[\s]+KEY@', $create_query)) {
// split the query into lines, so we can easilly handle it // Split the query into lines, so we can easily handle it. We know lines are separated by $crlf (done few lines above).
if (strpos(",\r\n ", $create_query) === FALSE) { $sql_lines = explode($crlf, $create_query);
$sql_lines = preg_split('@\r|\n@', $create_query);
} else {
$sql_lines = preg_split('@\r\n@', $create_query);
}
$sql_count = count($sql_lines); $sql_count = count($sql_lines);
// lets find first line with constraints // lets find first line with constraints