Gossamer Forum
Quote Reply
Second Condition
Can this global have a second condition such as: isImg = yes. I have been trying to fit this in but getting noware fast! Unsure

Code:
sub {
my $tags = shift;
my $link_db = $DB->table('Links','CatLinks');
my $cat_id = $tags->{Rand_SS_CatID};
my $all_ids = $DB->table('Category')->children($cat_id);
push @$all_ids, $cat_id;
my $limit = $tags->{Random_Limit} || 3;
my (@output, $sth);
$link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
my $cond = GT::SQL::Condition->new('isValidated','=','Yes', 'CategoryID', 'IN', \@$all_ids);
if ($cat_id) {
$sth = $link_db->select ( $cond);
}
else {
$sth = $link_db->select({isValidated=>'Yes'});
}
while (my $link = $sth->fetchrow_hashref) {
push @output, $link;
}
return { Rand_SS_Loop => \@output }
}
Quote Reply
Re: [JohnOJ] Second Condition In reply to
Hi. Try this;

my $cond = GT::SQL::Condition->new('isValidated','=','Yes', 'isImg','=','yes', 'CategoryID', 'IN', \@$all_ids);

Cheers

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!