Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: fetchrow_array return value

by mpeppler (Vicar)
on Jan 10, 2004 at 00:05 UTC ( #320254=note: print w/replies, xml ) Need Help??


in reply to fetchrow_array return value

If you use fetchrow_array() like that then if there are one or more rows returned then the first one is lost, because you threw it away in the if().

Why not do something like:

my $found = 0; while(my @row = $sth->fetchrow_array) { ++$found; ... process @row ... } if(!$found) { ... no rows found ... }
As for using $sth->rows(), the problem is that for most database engines the number of rows affected by a SELECT query can only be determined once all of the rows have been fetched...

Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://320254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2022-10-05 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (25 votes). Check out past polls.

    Notices?