Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: fetchrow_array return value

by mpeppler (Vicar)
on Jan 10, 2004 at 00:05 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-19 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found