Re: ruby/postgres - getting assoc array of rows? - Mailing list pgsql-interfaces

From Michael Fuhr
Subject Re: ruby/postgres - getting assoc array of rows?
Date
Msg-id 20051120055226.GA31492@winnie.fuhr.org
Whole thread Raw
In response to Re: ruby/postgres - getting assoc array of rows?  (Michael Fuhr <mike@fuhr.org>)
List pgsql-interfaces
On Sat, Nov 19, 2005 at 10:32:47PM -0700, Michael Fuhr wrote:
> You could also convert the PGresult object into an array of PGrow
> objects with a one-liner, although you wouldn't get automatic bytea
> handling as in the function you posted:
> 
> rows = res.collect

Other possibilities are res.to_a, res.entries, res.result, and
res.rows, which all do the same thing: return an array of PGrow
objects.  The collect, to_a, and entries methods are provided by
the Enumerable mixin; the result and rows methods are aliases for
entries, which is synonymous with to_a.  Using any of these methods
ultimately results in calling PGresult#each, which yields the PGrow
objects.

-- 
Michael Fuhr


pgsql-interfaces by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: ruby/postgres - getting assoc array of rows?
Next
From: CSN
Date:
Subject: Re: ruby/postgres - getting assoc array of rows?