Front page | perl.dbi.users |
Postings from February 2012
Re: selectall_arrayref
Thread Previous
From:
Greg Sabino Mullane
Date:
February 21, 2012 14:19
Subject:
Re: selectall_arrayref
Message ID:
2fd24de051fa1fb8acb1d1e2f014bfe4@biglumber.com
-----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 greg@turnstep.com
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-----
Thread Previous