For completeness, please note that this is a limitation of DBD::mysql, not of MySQL. From the MySQL documentation:
ROW_COUNT() returns the number of rows changed, deleted, or inserted b +y the last statement if it was an UPDATE, DELETE, or INSERT.
Unfortunately it also says below:For UPDATE statements, the affected-rows value by default is the numbe +r of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag + to mysql_real_connect() when connecting to mysqld, the affected-rows + value is the number of rows “found”; that is, matched by the WHERE c +lause.
Which I take it is the reason why it doesn't even work to call that function directly (through DBI) as in:Important ROW_COUNT() is not replicated reliably.
. . . which still returns the number of "found" rows (those that match the where clause), not the number of changed rows, as do $sth->rows and the return value of $dbh->do. This is very odd, in my view, since when I run that same SQL in the MySQL CLI, it does return the number of changed rows.my $rows = $dbh->selectrow_array( 'select row_count()' );
In reply to Re: [Solved]: How to get count of rows changed by MySQL UPDATE command using DBI
by 1nickt
in thread [Solved]: How to get count of rows changed by MySQL UPDATE command using DBI
by Perl300
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |