Dear Friends,
$sth-rows() returns "affected rows 1" even if there is no change in
the database while update. How do I get "0" when there is no change
in the database?
Any help would be appreciated.
The following is my code.
use strict;
use warnings;
use DBI;
my($dbi);
DBConnect("localhost", "", "test", "root", "root");
my $sql;
$sql = "update mydb set textfield=\"sometext\" where id=\"1\"";
my ($sth);
$sth = $dbi->prepare($sql);
$sth->execute();
print "\n affected rows:", $sth->rows();
sub DBConnect
{
my($host,$port,$database,$user,$passwd) = @_;
my $dsn
= "DBI:mysql:$database:$host:$port:mysql_client_found_rows=0";
$dbi = DBI->connect($dsn,$user,$passwd, {AutoCommit => 1,
RaiseError => 1}) || die return DBI->errstr;
}
Regards
Vijay