in reply to Re: DBI hashref does not return data in order of query
in thread DBI hashref does not return data in order of query
And here is the response from the Dumper:my @names = @{ $sth->{NAME_uc} }; my @ordered_values = (); while ( my $row = $sth->fetchrow_hashref ) { @ordered_values = @{$row}{@names}; } print Dumper(\@names); print Dumper(\@ordered_values); my $cgi = CGI->new; print $cgi->header('text/xml'); my $testxml = XMLout( \@ordered_values, NoAttr => 1, RootName => 'dataset', ); print $testxml;
So @names is correct, but in the @ordered_values, I am getting a bunch of blank fields (checked if it was a query problem, it's not), and that gibberish line is actually data(the GC_ID field). Can you see what's wrong with the push I am doing? The XML::Simple function seems to want a hash of the data so it can put the key in the element tag, and the hash value inside the tags? <edit> Empty data was cause of the NAME_uc. Changed to NAME and it plugged in data, but everything still is ANON. Update This while loop also seems to overwrite the data in the @ordered_values array as when I print using XMLout (XML::Simple), there is only one XML entry.$VAR1 = [ 'NPA', 'GC_ID', 'I_TG_NAME', 'E_TG_NAME', 'DN', 'STATE' ]; $VAR1 = [ undef, 'AAAABUcKyqQhEAABI34stA.4515613', undef, undef, undef, undef ]; Content-Type: text/xml; charset=ISO-8859-1 <dataset> <anon></anon> <anon>AAAABUcKyqQhEAABI34stA.4515613</anon> <anon></anon> <anon></anon> <anon></anon> <anon></anon> </dataset>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: DBI hashref does not return data in order of query
by erix (Prior) on Oct 28, 2007 at 23:38 UTC | |
by hallikpapa (Scribe) on Oct 28, 2007 at 23:46 UTC | |
by erix (Prior) on Oct 29, 2007 at 01:05 UTC | |
by hallikpapa (Scribe) on Oct 29, 2007 at 03:51 UTC |