Search the web
Sign In
New User? Sign Up
perl-beginner · Perl Beginners Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
MySql: How to find whether any rows affected or not?   Message List  
Reply | Forward Message #26312 of 26744 |
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





Mon Jul 21, 2008 1:11 pm

mp_vijayakumar
Offline Offline
Send Email Send Email

Forward
Message #26312 of 26744 |
Expand Messages Author Sort by Date

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...
Vijaya Kumar
mp_vijayakumar
Offline Send Email
Jul 21, 2008
1:11 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help