gpt4 book ai didi

php - 如何用php判断INSERT IGNORE是否通过?

转载 作者:行者123 更新时间:2023-11-29 12:49:34 25 4
gpt4 key购买 nike

我想检查一下,如果这段代码

mysql_query("INSERT IGNORE 
INTO `popupip` (`userid` ,`ownerid`,`ip` ,`date` ,`ref`)
VALUES ('$secid', $ownerid, '$date' , '$ref');"
);

已插入表,要做一些工作。

if (condition) {
// is not duplicated and I should pay to him/her
} else {
// is duplicated an I shouldn't pay to him/her
}

我应该为条件添加什么?

注意:useridowneridipdate 的组合是唯一的

最佳答案

这应该可以解决 SQL 错误和重复条目的问题。

  if(mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()))
{
if(mysql_affected_rows($link)==1){
//insert took place
}else{
//no insert
}
}

关于php - 如何用php判断INSERT IGNORE是否通过?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24971629/

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