Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 一次插入多个值,同时检查是否重复_Php_Mysql_Mysqli - Fatal编程技术网

Php 一次插入多个值,同时检查是否重复

Php 一次插入多个值,同时检查是否重复,php,mysql,mysqli,Php,Mysql,Mysqli,大家好,我正在通过此查询插入数据 insert into doc_share (docid,did,coid,eid) values ('$val','$some','$thing','$here'), ('$val25','$some','$thing','$here'), ('$val33','$some','$thing','$here')... // only $val is changing other values are same 现在,在我的数据库中,我需要docid和did

大家好,我正在通过此查询插入数据

insert into doc_share (docid,did,coid,eid) values 
('$val','$some','$thing','$here'),
('$val25','$some','$thing','$here'),
('$val33','$some','$thing','$here')...
// only $val is changing other values are same
现在,在我的数据库中,我需要
docid
did
的唯一组合,我已经从表中完成了,但我想通过查询完成,因为即使有一个重复行,也不会插入行,即使是非重复行

如果可能的话,我想在将数据发送到数据库之前使用相同的查询检查是否有重复的行


请给我一些提示……

这是一个查询,不是多个查询。
docid
不是自动递增的吗?docid不是自动递增的o
did
是一个字段而不是单词。。是不是
did
=
$some
?您有4个值,但有5列..是的,did是一个字段而不是一个单词,很抱歉我编辑了代码4个值4列..:)我只需要检查docid和did的组合以使其唯一docid可以是任何内容,但did是相同的它仍将递增自动递增字段..没有“正确”的方法不递增自动递增字段。算了吧。如果你想这么做,你的应用程序逻辑有问题吗
insert IGNORE into doc_share (docid,did,coid,eid) values 
('$val','$some','$thing','$here'),
('$val25','$some','$thing','$here'),
('$val33','$some','$thing','$here')...