dpq59734 2010-12-26 14:42
浏览 84
已采纳

PHP代码 - 如何检查Mysql数据库中的重复条目

I am working on Google checkout API notification URL. I want to apply a check in my php code which will see if transaction ID present in transaction table of my DB, it will exit not process.

I am struggling into applying here. Can somebody help?

I want to check if trasaction ID exists in table of DB it will exit, it will not process:

case "new-order-notification":  
    $sql = "
        UPDATE
            transactions
        SET
            remote_trans_id=\"".$_REQUEST["google-order-number"]."\", updated=NOW() 
        WHERE
        id=".$_REQUEST["shopping-cart_items_item-1_merchant-item-id"]
        ;
    execute($sql, $conn);
break;

Regards

  • 写回答

4条回答 默认 最新

  • doushang1880 2010-12-28 10:28
    关注

    Just use INSERT ON DUPLICATE KEY UPDATE. This way mySql will do the checking for you, if is a new transaction will enter it otherwise will update the existing entry.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效