Gossamer Forum
Quote Reply
Help With Global
This Global objective is to determine how many links in each category have the custom column LinkType set to the value: Detailed.



Code:
sub { my $LinkType = "Products";
my $type = "Detailed";
my ($last,@dirs,$output,@cat_list,$linea,@ordena_cat,$howmany); my $home = 1;
my $complete = 0; # Purpose?


my ($katid, $tags) = @_;

my $cat_db = $DB->table('Category');
my $links_db = $DB->table('Links');
my $relation = $DB->table('CatLinks', 'Links');
my $relation2 = $DB->table('Category', 'Links');


my @root_cats = $cat_db->select (['Full_Name'], { FatherID => $tags })->fetchall_list;
my @id_cats = $cat_db->select (['ID'], { FatherID => $tags })->fetchall_list;


my $counter;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
@dirs = split (/\//, $root_cat);
$last = pop @dirs unless ($complete);

my $sth = $relation->select( { CategoryID => $id_cats[$counter] } );
my ($count) = $sth->fetchrow_array;


my $sth2 = $relation2->select( { 'Category.ID' => $id_cats[$counter] , LinkType => $type } );
my ($count2) = $sth2->fetchrow_array;


my $count3 = $cat_db->select({ ID => $id_cats[$counter] })->fetchrow_hashref;


#### $count3, $count2 and $count are tests

my $total_links = "$count3->{Number_of_Links} - $count2 - $count";
$cat_list[$counter] = "<li><a class='$last' href='$CFG->{build_root_url}/$LinkType/$url'>$last</a> $total_links<br>";
$counter++;
}


@ordena_cat = sort {uc($a) cmp uc($b)} @cat_list;

foreach $linea (@ordena_cat) {
$output .= qq~$linea~;
}
return $output;
}
Quote Reply
Re: [jaltuve] Help With Global In reply to
Almost forgot... I asked a co worker for help, he gave me this:

select count(*) from lsql_CatLinks c, lsql_Links l where c.CategoryID = 24 AND c.LinkID = l.ID AND l.LinkType = 'Detailed'

if I run that query in the query monitor IT WORKS!!! but I can;t make that query work with the GT libraries

I tried translating the above query into this:

my $count = $relation->count( { CategoryID => $id_cats[$counter] , LinkID => ID , LinkType => $type } );

it says something about bareword error....

Last edited by:

jaltuve: Mar 25, 2003, 7:05 PM
Quote Reply
Re: [jaltuve] Help With Global In reply to
Quote:
select count(*) from lsql_CatLinks c, lsql_Links l where c.CategoryID = 24 AND c.LinkID = l.ID AND l.LinkType = 'Detailed'

my $count = $relation->count({ CategoryID => 24, LinkType => 'Detailed' });
Quote Reply
Re: [Paul] Help With Global In reply to
Excelent paul. Thanks