in reply to JSON module
Using fetchrow_hashref you can do something like:
use strict; use warnings; use DBI; use JSON; my @output; my $dbh = DBI->connect('dbi:Pg:dbname=foo','bar','baz'); my $sth = $dbh->prepare('select * from qux'); $sth->execute; while ( my $row = $sth->fetchrow_hashref ){ push @output, $row; } print objToJson( { myData => \@output } );
It'd be killer on RAM with a lot of rows, though...
--
"Go up to the next female stranger you see and tell her that her "body is a wonderland."
My hypothesis is that she’ll be too busy laughing at you to even bother slapping you." (src)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: JSON module
by hallikpapa (Scribe) on Aug 14, 2007 at 05:54 UTC | |
by LTjake (Prior) on Aug 14, 2007 at 12:14 UTC | |
by hallikpapa (Scribe) on Aug 14, 2007 at 20:30 UTC | |
by LTjake (Prior) on Aug 15, 2007 at 12:06 UTC | |
by hallikpapa (Scribe) on Aug 15, 2007 at 21:49 UTC | |
|
In Section
Seekers of Perl Wisdom