This commit is contained in:
2023-10-05 15:15:50 +08:00
parent 0dd7b7e0e7
commit d942db93d8
+2 -3
View File
@@ -208,7 +208,6 @@ class BackupCommand extends Command
{ {
$strings = ['INSERT INTO ' . $dbname . '.' . $value]; $strings = ['INSERT INTO ' . $dbname . '.' . $value];
foreach ($data as $datum) { foreach ($data as $datum) {
if (count($strings) == 1) { if (count($strings) == 1) {
$keys = array_keys($datum); $keys = array_keys($datum);
$strings[] = '(' . implode(',', $keys) . ') VALUES'; $strings[] = '(' . implode(',', $keys) . ') VALUES';
@@ -217,9 +216,9 @@ class BackupCommand extends Command
$encode = []; $encode = [];
foreach ($keys as $val) { foreach ($keys as $val) {
if (is_string($val)) { if (is_string($val)) {
$encode[] = '\'' . htmlentities($val) . '\''; $encode[] = '\'' . addcslashes($val,'\'') . '\'';
} else { } else {
$encode[] = $val; $encode[] = $val === '' ? '\'\'' : $val;
} }
} }
$strings[] = '(' . implode(',', $encode) . '),'; $strings[] = '(' . implode(',', $encode) . '),';