Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Perl or SQL ?

by mpeppler (Vicar)
on Dec 22, 2005 at 08:38 UTC ( [id://518498]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl or SQL ?
in thread Perl or SQL ?

$sth->fetch returns an array reference, and $sth->fetchrow returns a list. Each item in the array or list is a column in the SELECT statement. So:

$sth = $dbh->prepare("select a, b, c from foo"); $sth->execute; while($row = $sth->fetch) { # $row->[0] is column 'a' # $row->[1] is column 'b', # etc... }
and
while(($one, $two, $three) = $sth->fetchrow_array) { # $one, $two and $three are columns a, b and c }
Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found