From: Michael Fuhr <mike@fuhr.org>
To: CSN <cool_screen_name90001@yahoo.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: ruby/postgres - getting assoc array of rows?
Date: Sat, 19 Nov 2005 22:52:27 -0700
Message-ID: <20051120055226.GA31492@winnie.fuhr.org> (raw)
In-Reply-To: <20051120053247.GA31157@winnie.fuhr.org>
References: <20051120041440.29069.qmail@web52902.mail.yahoo.com>
<20051120053247.GA31157@winnie.fuhr.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: mike@fuhr.org, cool_screen_name90001@yahoo.com
Subject: Re: ruby/postgres - getting assoc array of rows?
In-Reply-To: <20051120055226.GA31492@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox