laravel 模型有没有那种重复数据入库跳过的方法
我用模型工厂批量添加遇到了这个问题
// 执行写入
User::factory()
->times(10000)
->create();
报错
// 报错
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'nbeier@example.com' for key 'users_email_unique' (SQL: insert into `users` (`name`, `email`, `email_verified_at`, `password`, `remember_token`, `updated_at`, `created_at`) values (Kiarra Stehr Sr., nbeier@example.com, 2021-05-25 05:45:24, $2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi, VsdFMvuwb1, 2021-05-25 05:45:25, 2021-05-25 05:45:25))
找到一个可以写入重复跳过的 sql ,但是那个生成的数据看不到,我该如何处理
DB::insert('insert ignore into qm_card_codes (created_at, updated_at) values(?, ?, ?, ?)',[x, x])
推荐文章: