Hi,
I've been trying to work this out for almost 4 days now, and am still not really anywhere near as realistic solution :(
Basically, I want to use the following kind of code:
$tbl->select_options('ORDER BY Name ASC');
my $topcats = $tbl->select( { FatherID => $_[0] } );
my $rows = $topcats->rows || 0;
my $i = 0;
while (my $hit = $topcats->fetchrow_hashref) {
push @cats, $hit;
}
..but also do the Related categories into this same loop - with something like:
my $cat_db = $DB->table('Category');
my $opts = undef;
my %related_ids = $related_db->select(qw/RelatedID RelationName/ => { CategoryID => $_[0] })->fetchall_list;
my @cats;
if (keys %related_ids) {
$cat_db->select_options("ORDER BY $opts->{cat_sb} $opts->{cat_so}") if $opts->{cat_sb};
my $sth = $cat_db->select({ ID => [keys %related_ids] });
while (my $cat = $sth->fetchrow_hashref) {
my $url = $CFG->{build_root_url} . "/" . $cat_db->as_url($cat->{Full_Name}) . "/" . $CFG->{build_index};
$cat->{URL} = $url;
$cat->{Related} = 1;
push @cats, $cat;
}
}
As you can see, getting the hash's into the @cats array isn't the problem. The problem comes when I try and "sort" them (because you can't just do a simple MySQL ORDER BY statement, as the tables are totally separate).
Am I missing something really silly here? Any suggestions?
TIA!
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
I've been trying to work this out for almost 4 days now, and am still not really anywhere near as realistic solution :(
Basically, I want to use the following kind of code:
Code:
my $tbl = $DB->table('Category'); $tbl->select_options('ORDER BY Name ASC');
my $topcats = $tbl->select( { FatherID => $_[0] } );
my $rows = $topcats->rows || 0;
my $i = 0;
while (my $hit = $topcats->fetchrow_hashref) {
push @cats, $hit;
}
..but also do the Related categories into this same loop - with something like:
Code:
my $related_db = $DB->table('CatRelations'); my $cat_db = $DB->table('Category');
my $opts = undef;
my %related_ids = $related_db->select(qw/RelatedID RelationName/ => { CategoryID => $_[0] })->fetchall_list;
my @cats;
if (keys %related_ids) {
$cat_db->select_options("ORDER BY $opts->{cat_sb} $opts->{cat_so}") if $opts->{cat_sb};
my $sth = $cat_db->select({ ID => [keys %related_ids] });
while (my $cat = $sth->fetchrow_hashref) {
my $url = $CFG->{build_root_url} . "/" . $cat_db->as_url($cat->{Full_Name}) . "/" . $CFG->{build_index};
$cat->{URL} = $url;
$cat->{Related} = 1;
push @cats, $cat;
}
}
As you can see, getting the hash's into the @cats array isn't the problem. The problem comes when I try and "sort" them (because you can't just do a simple MySQL ORDER BY statement, as the tables are totally separate).
Am I missing something really silly here? Any suggestions?
TIA!
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

