Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: DBD::CSV failing

by bsdwolf (Initiate)
on Feb 03, 2006 at 00:26 UTC ( [id://527510]=note: print w/replies, xml ) Need Help??


in reply to Re^4: DBD::CSV failing
in thread DBD::CSV failing

Okay, I'm back (again). Using $sth->fetchrow_hashref seems to be solving my problem. I have discovered that one cannot use $sth->fetch if one chooses to execute a query containing conditionals based on fields; i.e.
$sth->prepare("SELECT * FROM db WHERE field < 2000"); while (@row = $sth->fetch) { ... }
will return the first row and then nothing beyond that. If I use
while ($row = $sth->fetchrow_hashref) { ...
for some reason, everything seems to be hunky dory. Also, that "undef" in setting up the column names and variable references also is wont to cause me difficulty ("perldoc DBD::CSV" for reference on that one). Go figure.
--*greywolf;
/* relayer halo gmail */

Replies are listed 'Best First'.
Re^6: DBD::CSV failing
by jZed (Prior) on Feb 03, 2006 at 01:02 UTC
    Your code:
    while (@row = $sth->fetch) # don't do this
    is wrong. In DBI, fetch() is an alias for fetchrow_arrayref so its return is a scalar (an array reference), not an array.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-29 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found