How to access arrays from DBD::Pg?

Started by Konstantinos Agourosalmost 25 years ago2 messagesgeneral
Jump to latest
#1Konstantinos Agouros
elwood@agouros.de

Hi,

I have some data, that I would like to store in array-columns. How can I access
this from DBD::Pg? Do I have to parse it manually?

Konstantin
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres

#2will trillich
will@serensoft.com
In reply to: Konstantinos Agouros (#1)
Re: How to access arrays from DBD::Pg?

On Sun, May 27, 2001 at 09:39:12PM +0200, Konstantinos Agouros wrote:

Hi,

I have some data, that I would like to store in array-columns. How can I access
this from DBD::Pg? Do I have to parse it manually?

that's how i do it. if there's another way i'd love to hear it.

sub trim { substr(@_[0],1,length(@_[0])-2) };
my $r = $sth->fetchrow_arrayref();
# $r->{arraycolumn} resembles {"one","two","three"} --
my @a = map{ &trim($_) } split /,/, &trim($r->{arraycolumn});
# presuming no array element contains a comma...!

--
#95: We are waking up and linking to each other. We are watching. But
we are not waiting. -- www.cluetrain.com

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!