Skip site navigation (1) Skip section navigation (2)

Re: ruby/postgres - getting assoc array of rows?

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 (view raw or flat)
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

In response to

pgsql-interfaces by date

Next:From: CSNDate: 2005-11-20 10:31:45
Subject: Re: ruby/postgres - getting assoc array of rows?
Previous:From: Michael FuhrDate: 2005-11-20 05:32:47
Subject: Re: ruby/postgres - getting assoc array of rows?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group