Gossamer Forum
Home : Products : DBMan : Customization :

sorting on multiple fields

Quote Reply
sorting on multiple fields
i am trying to figure out how to sort on multiple fields so i can sort by category and list the records within each category in alphabetical order. i have read everything (i think!) at the FAQ site, but my db.cgi does not look like the mods.
Code:

Then in db.cgi sub query comment out this:
# $in{'so'} ? ($order = $in{'so'}) : ($order = "ASC");
# $in{'sb'} and ($sortby = "ORDER BY $in{'sb'} $order");


and add:
my $order;
for (1 .. 6) {
$in{"sb$_"} and ($order .= qq~$in{"sb$_"} $in{"so$_"},~);
}
chop $order;
$order ? ($sortby = "ORDER BY $order") : ($sortby = '');

i don't have the lines that the above says to comment out. the closest thing i can find is :

Code:


# Sort the array @hits in order if we are meant to sort.
if (exists $in{'sb'}) { # Sort hits on $in{'sb'} field.
my ($sort_order, $sort_func);
$in{'so'} ? ($sort_order = $in{'so'}) : ($sort_order = "ascend");
$sort_func = "$db_sort{$db_cols[$in{'sb'}]}_$sort_order";

foreach $hit (sort $sort_func (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit; $last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sortedhits, @hits[$first .. $last]);
}
@hits = @sortedhits;
}

is this the right place? how do i adjust the mod to fit? i'm assuming that the code at FAQ was written for an older version of dbman? thanks for any help!

Last edited by:

delicia: Aug 24, 2004, 4:12 PM
Quote Reply
Re: [delicia] sorting on multiple fields In reply to
am i posting my question in the right place? please help!
Quote Reply
Re: [delicia] sorting on multiple fields In reply to
never mind. i guess the code i posted was actually for the mysql version. i have it working with the version that is not called condensed version.