From fd8ac37742328be88a8362c690ecf590808f46a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sat, 30 Sep 2023 20:03:15 +0800 Subject: [PATCH] eee --- ImplodeCommand.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ImplodeCommand.php b/ImplodeCommand.php index 31b61d6..47c9e2c 100644 --- a/ImplodeCommand.php +++ b/ImplodeCommand.php @@ -62,15 +62,31 @@ class ImplodeCommand extends Command $path = APP_PATH . $path; } - $waite = new Coroutine\WaitGroup(); + $waite = new Coroutine\WaitGroup(); $stream = fopen($path, 'r'); if ($stream) { while (($line = fgets($stream)) !== false) { - $insert = html_entity_decode($line); - if (!str_starts_with(strtoupper($insert), 'INSERT INTO')) { + if (!str_starts_with(strtoupper($line), 'INSERT INTO')) { continue; } $waite->add(); + [$one, $two] = explode('VALUES', $line); + $foreach = explode(',', $two); + + $array = []; + foreach ($foreach as $item) { + $values = explode(',', trim($item, '()')); + $tmp = []; + foreach ($values as $date) { + if (is_string($date)) { + $tmp[] = '\'' . html_entity_decode(trim($date, '\'')) . '\''; + } else { + $tmp[] = $data; + } + } + $array[] = implode(',', $tmp); + } + $insert = $one . ' VALUES ('.implode('),(', $array).')'; Coroutine::create(function () use ($waite, $insert, $data) { Coroutine\defer(fn() => $waite->done()); $data->createCommand($insert)->exec();