简体   繁体   English

mysql问题与删除记录

[英]mysql issue with delete of a record

I have a web page with a grid of row and columns and I need to keep track of activity that happens in a given cell. 我有一个包含行和列网格的网页,并且需要跟踪给定单元格中发生的活动。 Items can be moved around between cells so I keep a record in a MySQL table to track the contents of each cell. 项目可以在单元格之间移动,因此我在MySQL表中保留了一条记录以跟踪每个单元格的内容。 The key to the db record is row number and column number, for example, the key to the record representing row 2, column 7 is r2c7. db记录的键是行号和列号,例如,代表第2行,第7列的记录的键是r2c7。

When an item gets put into r2c7, I insert a record with r2c7 as the key field value. 当某项放入r2c7时,我插入一条记录,其中r2c7作为键字段值。 If the contents of r2c7 gets move to r3c8, I insert a record into r3c8 and delete the record for r2c7. 如果r2c7的内容移到r3c8,我将一条记录插入r3c8并删除r2c7的记录。 All is fine up to this point. 到目前为止,一切都很好。

What I am finding though, is that after I've deleted a record for a cell, say r2c7, if I then try to re-insert the same record back in for r2c7, the insert does not stick, even though MySQL reports success on the insert. 不过,我发现的是,在删除单元格的记录(例如r2c7)后,如果我尝试重新为r2c7重新插入相同的记录,即使MySQL报告成功,插入也不会停留插入。 To be clear, all fields in the record that I previously deleted, are the same when I go to re-insert. 需要明确的是,我以前删除的记录中的所有字段在我重新插入时都是相同的。 It seems the database sees a duplicate record trying to be re-inserted and does not process it, even though success is reported. 即使报告成功,数据库似乎仍然看到试图重新插入的重复记录,并且没有对其进行处理。

Anyone have an idea of what is going on? 任何人都知道发生了什么事吗?

Check mysqli_affected_rows($con) ; 检查mysqli_affected_rows($con) ; It will definitely gives you a false as return if the row insert was unsuccessfull 如果行插入不成功,肯定会为您提供错误的返回值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM