in reply to no rows returned for dbi fetchall_arrayref
fetchall_arrayref returns zero if the query failed
my $result_array = $sth->fetchall_arrayref; if (!$result_array) { print "query failed!!\n"; }
If no rows are found (the query is successful, but no rows are returned) fetchall_arrayref returns a reference to an empty array.
my $result_array = $sth->fetchall_arrayref; if ($result_array) { print "success\n"; if (@$result_array) { print "found rows @$result_array\n"; } else { print "no rows returned\n"; } } else { print "query failed!!\n"; }
|
---|
In Section
Seekers of Perl Wisdom