On Thu, Jan 15, 2004 at 10:20:51AM -0600, Daniel S. Lewart wrote:
> Tim,
>
> > Can you let me know if you plan to do this sometime soon?
>
> I've had something every night this week. I can do it this weekend.
>
> > Otherwise I'll ask for volunteers to polish it up as I'd like to
> > get it the next release.
>
> If this weekend isn't soon enough, that's fine with me.
Dan, any news?
Tim.
On Sat, Jan 10, 2004 at 10:27:44PM +0000, Tim Bunce wrote:
>
> Just to fill that requirement out some more... here's some untested code
> that I think will get you most of the way there:
>
> my $hash_key_name = $sth->{FetchHashKeyName} || 'NAME';
> my $names_hash = $sth->FETCH("${hash_key_name}_hash");
>
> my @key_fields = (ref $key_field) ? @$key_field : ($key_field);
> my @key_values;
> foreach (@key_fields) {
>
> my $index = $names_hash->{$_}; # perl index not column
> ++$index if defined $index; # convert to column number
> $index ||= $key_field if DBI::looks_like_number($key_field) &&
> $key_field>=1;
>
> push @key_values, undef;
> $sth->bind_col($index, \$key_value[-1]) or return;
> }
>
> my $rows = {};
> my $NAME = $sth->{$hash_key_name};
> while (my $row = $sth->fetchrow_arrayref($hash_key_name)) {
> my $ref = $rows;
> $ref = $ref->{$_} ||= {} for @key_values;
> @[EMAIL PROTECTED] = @$row;
> }
> return \%rows;