Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL timestamp record being updated but affected rows remains 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.

like image 678
Jason Lewis Avatar asked Sep 21 '11 19:09

Jason Lewis


1 Answers

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.

like image 134
Jason Lewis Avatar answered Sep 30 '22 22:09

Jason Lewis