34 lines
908 B
PHP
34 lines
908 B
PHP
<?php
|
|
|
|
namespace App\Tasks\MassInsert;
|
|
|
|
use App\Models\Transaction;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\DB;
|
|
use PHPUnit\Event\Runtime\PHP;
|
|
|
|
class MassInsert2Task
|
|
{
|
|
|
|
/**
|
|
* insert multiple
|
|
*
|
|
* 100 ............ 0,015 s DONE
|
|
* 1000 ............ 0,087 s DONE
|
|
* 10000 ............ 0,789 s DONE
|
|
* 100000 - SQLSTATE[HY000]: General error: 7 number of parameters must be between 0 and 65535
|
|
* 1000000 - 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());
|
|
}
|
|
}
|