MySQL 时间戳记录正在更新,但受影响的行仍为 0
还有一些类似的问题,但我会将其放在一起。
基本上,我有一个时间戳列(它是一个int),我的更新之一只是更新此时间戳列,有时它的距离几乎不可察觉。例如,它可能从 1316631442 更改为 1316631877。两者之间并没有太大区别。
因此记录正在更新,我可以在查询运行之前检查 phpMyAdmin,然后再检查,看看有什么不同。但是,我正在对受影响的行计数执行 var_dump(),它仍然为 0。
如果我同时将另一列更新为不同的值,则受影响的行为 1。
那么需要什么才能触发该行受到影响?尽管更新成功后它受到了影响。
另外,我正在使用 Laravel PHP 框架及其查询生成器。目前正在那里进行一些调试,看看是否有问题,但到目前为止一切似乎都很好。
编辑:抱歉我上面打错了一些内容。当我完全更改另一列的值时,受影响的行为 1,而不是 0。
There are a few similar questions but I'll throw this in the mix.
Basically, I have a timestamp column (which is an int) and one of my updates is ONLY updating this timestamp column and sometimes it's a barely noticeable distance. For instance, it might change from 1316631442 to 1316631877. Not really much of a difference between the two.
So the record is being updated, I can check in phpMyAdmin before the query is run and then afterward and see the difference. However, I'm doing a var_dump() on the affected row count and it remains 0.
If I update another column at the same time to a different value then the affected rows are 1.
So what does it take to trigger the row as being affected? Even though it's being affected since the update is successful.
Also, I'm using the Laravel PHP framework and its query builder. Currently doing a bit of debugging in there to see if something may be off but so far all seems to be well.
EDIT: Sorry I had mistyped something above. When I completely change another column's value the affected rows is 1, not 0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些好奇的人,我求助于使用 INSERT INTO...ON DUPLICATE KEY UPDATE 来实现所需的结果。我仍然不明白为什么 MySQL 没有报告受影响的记录。
我还尝试使用 PHP mysql_query() 和相关函数来检查受影响的行,但它也不起作用。也许 MySQL 认为该更改不值得将记录标记为受影响。
For those curious I resorted to using an INSERT INTO... ON DUPLICATE KEY UPDATE to achieve the desired result. I still couldn't figure out why MySQL wasn't reporting the record as being affected.
I also tried using PHPs mysql_query() and related functions to check the affected row but it didn't work like that also. Perhaps MySQL doesn't deem the change to be worthy of marking the record as affected.
我可以使用 MySql 5.1 重现该问题,但无法使用 Mysql 5.7 重现该问题。
在早期版本中
确实更新了时间戳,但消息是零行受到影响。
对于更高版本的 MySql,相同的查询使我的一行受到影响。
这似乎是 MySql 的一个错误,已被修复。
是时候让服务器管理员更新一些东西了吗?
I can replicate the issue with MySql 5.1 but not with Mysql 5.7.
In the earlier version
does update the timestamp but the message is that zero rows have been affected.
With the later version of MySql the same query gives me one row affected.
It seems to be a MySql bug that has been fixed.
Time to get the Server admin to update some stuff?