On Sun, Nov 06, 2005 at 10:30:48AM -0500, Walter Lewis wrote:
> I'm breaking a bit with my preferred style and including the whole
> thread in the posting because it's been nearly a month since I started
> the thread. October seems to be meeting and conference month ... and so
> here I am on a Sunday morning ...
>
> Mike Rylander put me on the track of mapping the hashes into an ordered
> list.
>
> The code evolved to:
>
> if (@ordered_sql_rows) {
> for (my $i = 0; $i <= $#ordered_sql_rows; $i++) {
> foreach my $key (keys %{$ordered_sql_rows[$i]}) {
> print ($key. ": " .$ordered_sql_rows[$i]{$key}. "<br />\n"); }
> }
> }
Perhaps write it another way:
my $results = $swish->Execute( $query );
[...]
my @swish_results;
while ( (my $result = $results->NextResult) && $page_size-- ) {
push @swish_results, $result;
}
my @ids = map { $_->Property( 'id' ) } @swish_results;
my %where = ( id => [EMAIL PROTECTED] );
my $sql = SQL::Abstract->new;
my ($stmt, @bind) = $sql->select($table,[EMAIL PROTECTED], \%where);
my $sth = $dbh->prepare( $stmt );
$sth->execute( @bind );
# check errors...
then:
my $recs = $sth->fetchall_hashref('id');
my @results = map { $recs->{$_} } @ids;
then pass @results to your view/template for output.
use Data::Dumper;
print Dumper [EMAIL PROTECTED];
Maybe better, if you don't trust swish and the db to be in sync:
my @results = map { $recs->{$_} } grep { exists $recs->{$_} } @ids;
Or whatever should happen when an item is not found.
--
Bill Moseley
[EMAIL PROTECTED]