douxiaomang5640 2015-11-26 10:04
浏览 17
已采纳

2删除,只有一个工作[POSTGRESQL]

I'm literaly going crazy over this one. So I have my gamePage.php file where I can see all the info about a single videogame. The button delete invokes the following code

    if(isset($_POST['delete'])){
        $query="DELETE FROM shop.videogame WHERE IDVideogame='$id'";
        pg_query($conn, $query);
        $query="DELETE FROM shop.storage WHERE videogame='$id'";
        pg_query($conn,$query);
        echo 'Game deleted, click the "Go Back" button';            
     }

What actually happens is that only the second Delete works. The videogame is deleted from the storage table, but not from the videogame table. What's even stranger is that if I click a second time the button, the first DELETE finally works.

In other words one is supposed to click for 2 times the same button for no reason.

  • 写回答

1条回答 默认 最新

  • dongtangu6889 2015-11-26 10:34
    关注

    I guess shop.storage.videogame is a ForeignKey to shop.videogame.IDVideogame.

    If I have right, then switch delete statements.

    $query="DELETE FROM shop.storage WHERE videogame='$id'";
    pg_query($conn, $query);
    $query="DELETE FROM shop.videogame WHERE IDVideogame='$id'";
    pg_query($conn, $query);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料