I'm trying to write a global to select 20 random links without reviews. I have worked out the SQL statement required but am having trouble getting it to return anything in Links:
# Displays 20 random links with no review
my ($output,$sth,$link);
my $search_db = $DB->table('Links', 'Reviews');
$search_db->select_options ('ORDER BY RAND()', 'LIMIT 20');
$sth = $search_db->select (GT::SQL::Condition->new('isValidated', '=',' Yes', 'Review_LinkID', 'IS', 'NULL'));
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 26) {
$link->{Titleshort} = substr($link->{Title}, 0, 25) . '...';
}
$output .= Links::SiteHTML::display ('templatename', $link);
}
return $output;
}
I suspect the 'Review_LinkID is NULL' part is the problem, nothing I have tried has worked. Any suggestions appreciated
.
Code:
sub { # Displays 20 random links with no review
my ($output,$sth,$link);
my $search_db = $DB->table('Links', 'Reviews');
$search_db->select_options ('ORDER BY RAND()', 'LIMIT 20');
$sth = $search_db->select (GT::SQL::Condition->new('isValidated', '=',' Yes', 'Review_LinkID', 'IS', 'NULL'));
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 26) {
$link->{Titleshort} = substr($link->{Title}, 0, 25) . '...';
}
$output .= Links::SiteHTML::display ('templatename', $link);
}
return $output;
}
I suspect the 'Review_LinkID is NULL' part is the problem, nothing I have tried has worked. Any suggestions appreciated
