The
execute() method called from your statement handle returns the number of affected rows, as does
$sth->{'mysql_affected_rows'}.
*NOTE* I'm think this is mysql specific for selects
You probably want something like:
my $sth = $dbh->prepare(
"SELECT * FROM poll
WHERE status='waiting'
ORDER BY `id` ASC
LIMIT 0, 5"
);
my $query_count = $sth->execute or die $dbh->errstr;
if ( $query_count == 1 ) {
# you *can* pull one but just one row using one of the
# fetch* methods
} else {
# your condition isn't met
}