in reply to DBD::MYSQL rows updated

Hi
Seems that ->execute() doesn't return affected rows.
mysql_client_found_rows
Enables (TRUE value) or disables (FALSE value) the flag CLIENT_FOUND_ROWS while connecting to the MySQL server. This has a somewhat funny effect: Without mysql_client_found_rows, if you perform a query like
UPDATE $table SET id = 1 WHERE id = 1
then the MySQL engine will always return 0, because no rows have changed. With mysql_client_found_rows however, it will return the number of rows that have an id 1, as some people are expecting. (At least for compatibility to other engines.)
From DBD::MySQL.

You should do a.... ->do(), or consider using something like (as mentioned on node 377155):

sub do {
      my($dbh, $statement, $attr, @bind_values) = @_;
      my $sth = $dbh->prepare($statement, $attr) or return undef;
      $sth->execute(@bind_values) or return undef;
      my $rows = $sth->rows;
      ($rows == 0) ? "0E0" : $rows; # always return true if no error
  }

Replies are listed 'Best First'.
Re^2: DBD::MYSQL rows updated
by zacc (Novice) on Nov 22, 2007 at 22:33 UTC
    OK - do does it. Fantastic - thanks