測試表遷移檔案:
public function up()
{
Schema::create('location_points', function (Blueprint $table) {
$table->id();
$table->string('province', 20)->nullable()->comment('省');
$table->string('city', 20)->nullable()->comment('市');
$table->decimal('lng', 11, 8)->nullable()->comment('經度');
$table->decimal('lat',11,8)->nullable()->comment('緯度');
$table->timestamps();
});
}
資料填充檔案:
public function run()
{
$data = [];
$date = date('Y-m-d H:i:s');
foreach (range(0,10000) as $key => $value){
$data[] = [
'province' => '山東省'.($key+1),
'city' => '濟南'.($key+1),
'lng' => rand(0, 179) + (mt_rand()/mt_getrandmax()),
'lat' => rand(0,89) + (mt_rand()/mt_getrandmax()),
'created_at' => $date,
'updated_at' => $date
];
}
$bool = \Illuminate\Support\Facades\DB::table('location_points')
->insert($data);
Log::info('建立10000條測試資料狀態:'. $bool);
}
問題:
我迴圈10000次資料能新增成功, 20000次就會包一大段錯誤, 目前看問題的提示是佔位符使用太多.
本作品採用《CC 協議》,轉載必須註明作者和本文連結