Re: selectall_arrayref

"Greg Sabino Mullane" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> my $ary_ref  = $dbh->selectall_arrayref($sql,{ Slice => {} }); #maybe I 
> should be using Slice in this case?

Yes, you want Slice, as we want to get the column names.

> my $names = do something to ary_ref to get another array ref of the id column
> my $ids = do something else to ary_ref to get a hash ref to the name column
>
> @h = checkbox_group(-name=>'selection',-values=>$ids, -labels=>$names);

I think you have the variable names reversed above, but you can do this, 
assuming a table with columns "id" and "name":

my $ary_ref = $dbh->selectall_arrayref($SQL, { Slice => {} });

my $ids = [ map { $_->{id} } @$abc ];

my $labels = { map { $_->{id}, $_->{name} } @$abc };

- -- 
Greg Sabino Mullane [email protected]
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201202211718
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAk9EGFwACgkQvJuQZxSWSsgeBwCfRKzaRduVyXMmEyAuSoPcg8NR
KdwAoLwbIHKPbj2ASq18pHw/qrFiqmtl
=ZTe5
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.