eee
This commit is contained in:
+19
-3
@@ -62,15 +62,31 @@ class ImplodeCommand extends Command
|
|||||||
$path = APP_PATH . $path;
|
$path = APP_PATH . $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$waite = new Coroutine\WaitGroup();
|
$waite = new Coroutine\WaitGroup();
|
||||||
$stream = fopen($path, 'r');
|
$stream = fopen($path, 'r');
|
||||||
if ($stream) {
|
if ($stream) {
|
||||||
while (($line = fgets($stream)) !== false) {
|
while (($line = fgets($stream)) !== false) {
|
||||||
$insert = html_entity_decode($line);
|
if (!str_starts_with(strtoupper($line), 'INSERT INTO')) {
|
||||||
if (!str_starts_with(strtoupper($insert), 'INSERT INTO')) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$waite->add();
|
$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::create(function () use ($waite, $insert, $data) {
|
||||||
Coroutine\defer(fn() => $waite->done());
|
Coroutine\defer(fn() => $waite->done());
|
||||||
$data->createCommand($insert)->exec();
|
$data->createCommand($insert)->exec();
|
||||||
|
|||||||
Reference in New Issue
Block a user