gpt4 book ai didi

php - 拉维尔 5 : insert row with possibility of duplication

转载 作者:行者123 更新时间:2023-11-30 22:32:04 25 4
gpt4 key购买 nike

如何在唯一列中插入可能重复的行并返回是否插入项目?

尝试过:

$id = DB::insert("INSERT IGNORE INTO question (id,text) values (10,'test')");

但是 $id 总是返回值 = 1

也试过:

$id = DB::table('question')->insertGetId(['id' => 10, 'text' => 'test'])->ignore();

但是ignore()没有效果!

最佳答案

try {
DB::table('arv_groups')->insert([
'grouphash' => $grouphash,
'id_photo' => $id
]);
} catch(\Illuminate\Database\QueryException $e){
// I DON'T CARE IT'S DUPLICATE !!! THANK YOU VERY MUCH!
}

关于php - 拉维尔 5 : insert row with possibility of duplication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33610786/

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