SPUG:using DBI::fetchrow_array(); to load another array
Creede Lambard
creede at penguinsinthenight.com
Mon Feb 10 11:32:38 CST 2003
On Mon, 2003-02-10 at 05:04, Chris Wilkes wrote:
> Later on in the perldoc for DBI it has
> $ary_ref = $sth->fetchall_arrayref;
> which I think is what you're thinking about.
For some reason I have better luck with fetchrow_hashref. Same general
idea, just returns a hash reference to the row you're looking for.
my $query = "select * from foo";
my $sth = $dbh->prepare($query);
$sth->execute;
while (my $row = $sth->fetchrow_hashref()) {
print Dumper $row;
}
Members of $row are accessed by dereffing the hash, e.g. $row->{id} .
--
* .~. `( --------------------------------------------------------------
` / V \ . Creede Lambard : error in /usr/bin/breakfast -
/( )\ creede at penguinsinthenight.com : cereal port not responding
^^-^^ --------------------------------------------------------------
Perl Programmer and Linux Sysadmin, reasonable rates. Inquire within.
GPG key at http://www.penguinsinthenight.com/creede_public_key.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030210/291eb0a0/attachment.bin
More information about the spug-list
mailing list