| From: | Michael Fuhr <mike(at)fuhr(dot)org> |
|---|---|
| To: | CSN <cool_screen_name90001(at)yahoo(dot)com> |
| Cc: | pgsql-interfaces(at)postgresql(dot)org |
| Subject: | Re: ruby/postgres - getting assoc array of rows? |
| Date: | 2005-11-20 05:52:27 |
| Message-ID: | 20051120055226.GA31492@winnie.fuhr.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | CSN | 2005-11-20 10:31:45 | Re: ruby/postgres - getting assoc array of rows? |
| Previous Message | Michael Fuhr | 2005-11-20 05:32:47 | Re: ruby/postgres - getting assoc array of rows? |