Gossamer Forum
Quote Reply
Review by ID
How do I modify the following global so the random review it's calling is taken from just 1 particular ID number?
Code:
sub {
my $tags = shift;
my $review_db = $DB->table('Reviews');
my $limit = $tags->{Random_Limit} || 1;
my (@output, $sth);
$link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
$sth = $review_db->select();
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { random_reviews => \@output }
}

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Review by ID In reply to
So far so good!

this work except reviews are returned validated yes or no.

Code:
sub {
# Return 1 rand review for stated link ID
my $tags = shift;
my $review_db = $DB->table('Reviews');
my $link_id = $tags->{Random_LinkID};
my $limit = $tags->{Random_Limit} || 1;
my (@output, $sth);
$review_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
$sth = $review_db->select ( { Review_LinkID => $link_id });
#$sth = $review_db->select();
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { Rand_Review_Loop => \@output }
}

<%set Random_LinkID = 7%>

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Review by ID In reply to
Try;

Code:
sub {
# Return 1 rand review for stated link ID
my $tags = shift;
my $review_db = $DB->table('Reviews','Links');
my $link_id = $tags->{Random_LinkID};
my $limit = $tags->{Random_Limit} || 1;
my (@output, $sth);
$review_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
$sth = $review_db->select ( { Review_LinkID => $link_id }, { isValidated => 'Yes' });
#$sth = $review_db->select();
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { Rand_Review_Loop => \@output }
}

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!