mirror of
https://github.com/processwire/processwire.git
synced 2025-08-07 23:38:29 +02:00
Fix issue processwire/processwire-issues#1881
This commit is contained in:
@@ -49,7 +49,7 @@
|
|||||||
* ~~~~~
|
* ~~~~~
|
||||||
* #pw-body
|
* #pw-body
|
||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2024 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -834,10 +834,14 @@ class WireDatabaseBackup {
|
|||||||
if(in_array($table, $options['excludeExportTables'])) continue;
|
if(in_array($table, $options['excludeExportTables'])) continue;
|
||||||
$numTables++;
|
$numTables++;
|
||||||
$columns = array();
|
$columns = array();
|
||||||
|
$columnTypes = array();
|
||||||
$query = $database->prepare("SHOW COLUMNS FROM `$table`");
|
$query = $database->prepare("SHOW COLUMNS FROM `$table`");
|
||||||
$query->execute();
|
$query->execute();
|
||||||
/** @noinspection PhpAssignmentInConditionInspection */
|
/** @noinspection PhpAssignmentInConditionInspection */
|
||||||
while($row = $query->fetch(\PDO::FETCH_NUM)) $columns[] = $row[0];
|
while($row = $query->fetch(\PDO::FETCH_NUM)) {
|
||||||
|
$columns[] = $row[0];
|
||||||
|
$columnTypes[] = $row[1];
|
||||||
|
}
|
||||||
$query->closeCursor();
|
$query->closeCursor();
|
||||||
$columnsStr = '`' . implode('`, `', $columns) . '`';
|
$columnsStr = '`' . implode('`, `', $columns) . '`';
|
||||||
|
|
||||||
@@ -862,9 +866,12 @@ class WireDatabaseBackup {
|
|||||||
while($row = $query->fetch(\PDO::FETCH_NUM)) {
|
while($row = $query->fetch(\PDO::FETCH_NUM)) {
|
||||||
$numInserts++;
|
$numInserts++;
|
||||||
$out = "\nINSERT INTO `$table` ($columnsStr) VALUES(";
|
$out = "\nINSERT INTO `$table` ($columnsStr) VALUES(";
|
||||||
foreach($row as $value) {
|
foreach($row as $key => $value) {
|
||||||
|
$columnType = $columnTypes[$key];
|
||||||
if(is_null($value)) {
|
if(is_null($value)) {
|
||||||
$value = 'NULL';
|
$value = 'NULL';
|
||||||
|
} else if(stripos($columnType, 'bit') === 0 && ctype_digit("$value")) {
|
||||||
|
// leave bit column value unquoted
|
||||||
} else {
|
} else {
|
||||||
if($hasReplace) foreach($options['findReplace'] as $find => $replace) {
|
if($hasReplace) foreach($options['findReplace'] as $find => $replace) {
|
||||||
if(strpos($value, $find)) $value = str_replace($find, $replace, $value);
|
if(strpos($value, $find)) $value = str_replace($find, $replace, $value);
|
||||||
|
Reference in New Issue
Block a user