Hello,
I have a problem to bring a SQL statement into the right syntax within a global:
I want to show the last 10 Links in certain categories. Some of these links are in two or more categories. And thats why my global shows them more then one time. But this isn't very useful.
I want to show only unique links for instance with SQL »distinct«. How do I do that, what is the correct syntax in a global?
My global:
lastlinks
sub {
my $id = shift;
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY Add_Date DESC', 'LIMIT 10');
my $sth = $db->select ( { 'CatLinks.CategoryID' => ['7','8','9']}, [ 'Links.Title', 'Links.Add_Date'], { isValidated => 'Yes'} );
my @lasttenlinks;
while (my $link = $sth->fetchrow_hashref) {
push (@lasttenlinks, $link);
}
return { lastlinks_loop => \@lasttenlinks };
}
Thank you,
Stephan
I have a problem to bring a SQL statement into the right syntax within a global:
I want to show the last 10 Links in certain categories. Some of these links are in two or more categories. And thats why my global shows them more then one time. But this isn't very useful.
I want to show only unique links for instance with SQL »distinct«. How do I do that, what is the correct syntax in a global?
My global:
lastlinks
sub {
my $id = shift;
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY Add_Date DESC', 'LIMIT 10');
my $sth = $db->select ( { 'CatLinks.CategoryID' => ['7','8','9']}, [ 'Links.Title', 'Links.Add_Date'], { isValidated => 'Yes'} );
my @lasttenlinks;
while (my $link = $sth->fetchrow_hashref) {
push (@lasttenlinks, $link);
}
return { lastlinks_loop => \@lasttenlinks };
}
Thank you,
Stephan