gpt4 book ai didi

php - SQLSTATE[23000] : Integrity constraint violation: 1062

转载 作者:行者123 更新时间:2023-11-30 22:02:14 26 4
gpt4 key购买 nike

User::updateOrCreate([
'identifier' => $user->id,
'username' => $user->nickname,
'name' => $user->name,
'avatar' => $user->avatar,
'visibility' => $user->visibility,
'api_token' => Uuid::generate()
]);

还有我的迁移:

Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->integer('identifier')->unique();
$table->string('username')->unique();
$table->string('name');
$table->string('avatar');
$table->string('trade')->nullable();
$table->decimal('funds')->default(0);
$table->enum('visibility', [1, 2, 3]);
$table->uuid('api_token');
$table->timestamps();
});

但是会导致 QueryException :(

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '76561198364059468' for key 'users_identifier_unique'

最佳答案

此错误表示 users 表中有一行 identifier 的值已经为 76561198364059468。因此,只需使用唯一标识符即可避免错误。

关于php - SQLSTATE[23000] : Integrity constraint violation: 1062,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43035594/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com