31 lines
838 B
PHP
31 lines
838 B
PHP
<?php
|
|
|
|
namespace App\Tasks\Mass\MassInsert;
|
|
|
|
use App\Models\Transaction;
|
|
|
|
class MassInsert2Task
|
|
{
|
|
|
|
/**
|
|
* insert multiple
|
|
*
|
|
* 100 ............ 0,015 s DONE
|
|
* 1_000 ............ 0,087 s DONE
|
|
* 10_000 ............ 0,789 s DONE
|
|
* 100_000 - SQLSTATE[HY000]: General error: 7 number of parameters must be between 0 and 65535
|
|
* 1_000_000 - SQLSTATE[HY000]: General error: 7 number of parameters must be between 0 and 65535
|
|
*/
|
|
public function handle(int $count): void
|
|
{
|
|
if ($count >= 65535) {
|
|
echo 'QLSTATE[HY000]: General error: 7 number of parameters must be between 0 and 65535' . PHP_EOL;
|
|
|
|
return;
|
|
}
|
|
|
|
$transactions = Transaction::factory($count)->make();
|
|
Transaction::query()->insert($transactions->toArray());
|
|
}
|
|
}
|