This commit is contained in:
2023-10-05 15:33:18 +08:00
parent 0c2134a361
commit 2fb2111526
+3 -7
View File
@@ -102,7 +102,7 @@ class BackupCommand extends Command
defer(function () use ($waite) {
$waite->done();
});
$this->writeData( $input->getOption('database'), $value, $tmp);
$this->writeData($input->getOption('database'), $value, $tmp);
});
}
}
@@ -207,23 +207,19 @@ class BackupCommand extends Command
public function toSql(string $dbname, string $value, array $data): string
{
$strings = ['INSERT INTO ' . $dbname . '.' . $value];
$strings[] = '(' . implode(',', array_keys($data[0])) . ') VALUES';
foreach ($data as $datum) {
if (count($strings) == 1) {
$keys = array_keys($datum);
$strings[] = '(' . implode(',', $keys) . ') VALUES';
} else {
$keys = array_values($datum);
$encode = [];
foreach ($keys as $val) {
if (is_string($val)) {
$encode[] = '\'' . $val . '\'';
$encode[] = '\'' . addcslashes($val, '\'') . '\'';
} else {
$encode[] = $val === '' ? '\'\'' : $val;
}
}
$strings[] = '(' . implode(',', $encode) . '),';
}
}
return rtrim(implode('', $strings), ',') . ';';
}