$rows_affected = $dbh->do("UPDATE meters SET description=? WHERE name= +?", undef, $info, $meter);
Sometimes this query is issued with $info equal to the value already stored in that description field. The strange part is that $rows_affected is getting set to 1 even if $info is exactly the same as the existing value! I logged into the database manually and ran the query, which returned:
Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0
MySQL and Perl for the Web (p.37, footnote) says that "affected by" means "changed", and that do() should indeed return 0 in this case, unless I have ";mysql_client_found_rows=1" set, which I do not.
Guesses? Clues? Answers? Berating? I wish I had more information to provide about the problem...
Many thanks,
LassiLantar
Update: Fixed it, as per suggestion, by making the WHERE clause read ...WHERE name=? AND description=?", undef, $info, $meter, $info... Which resulted in return values of 0E0. Anyone know why MySQL or DBI is refusing to return just plain 0 in this case, and why it's returning 1 without the extra check?
In reply to Odd "rows affected" values using DBI on MySQL by LassiLantar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |