Subject: | Feature request: make arrayarray fetch column names as well. |
Date: | Tue, 4 Nov 2008 13:52:05 +0100 |
To: | <bug-POE-Component-EasyDBI [...] rt.cpan.org> |
From: | "Jensen, Troels" <Troels.BangJensen [...] RedPrairie.com> |
Hey,
I'm writing a program where I need to extract column names for SQL queries so I can display the output in tables.
However, the order is significant, so I need some kind of ordering - this means that I can't use the hashhash function since the column order will be arbitrary.
I've solved it with a small modification to the arrayarray function in SubProcess.pm which I'd like to see adopted.
The diff for my change in EasyDBI 1.23 is:
1276d1275
< my (@cols, %col);
1308,1314c1307
<
< # Find the column names
< for my $i ( 0 .. $sth->{NUM_OF_FIELDS}-1 ) {
< $col{$sth->{NAME}->[$i]} = $i;
< push(@cols, $sth->{NAME}->[$i]);
< }
<
---
Show quoted text
>
1329c1322
< $self->{output} = { rows => $rows, result => $result, cols=>[@cols],id => $data->{id}, chunked => $data->{chunked} };
---
Show quoted text> $self->{output} = { rows => $rows, result => $result, id => $data->{id}, chunked => $data->{chunked} };
1357c1350
< $self->{output} = { rows => $rows, result => $result, cols=>[@cols], id => $data->{id} };
---
Show quoted text> $self->{output} = { rows => $rows, result => $result, id => $data->{id} };
The data is already there in the return query, so it seems to me that my modification most likely wouldn't have an impact on performance.
Regards, Troels