eee
This commit is contained in:
+3
-7
@@ -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), ',') . ';';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user