LassiLantar has asked for the wisdom of the Perl Monks concerning the following question:
$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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Odd "rows affected" values using DBI on MySQL
by etcshadow (Priest) on Jul 24, 2004 at 19:57 UTC | |
by LassiLantar (Monk) on Jul 24, 2004 at 20:08 UTC | |
by ercparker (Hermit) on Jul 24, 2004 at 20:41 UTC | |
by LassiLantar (Monk) on Jul 24, 2004 at 20:46 UTC | |
by heroin_bob (Sexton) on Jul 25, 2004 at 00:21 UTC | |
by grantm (Parson) on Jul 24, 2004 at 21:49 UTC | |
by tilly (Archbishop) on Jul 24, 2004 at 21:56 UTC | |
by CountZero (Bishop) on Jul 24, 2004 at 22:01 UTC |