Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Links Custom Sort - part 2 (For Alex)

Quote Reply
Links Custom Sort - part 2 (For Alex)
Hi Alex,


There is an error in the script.


----------------------------
A fatal error has occured:
Failed to execute query: 'SELECT * FROM glinks_Links WHERE (isValidated = ?) AND CatLinks.CategoryID = ? ORDER BY N_State_Rank ASC LIMIT 10': Unknown column 'CatLinks.CategoryID' in 'where clause' at (eval 36) line 24.
Please enable debugging in setup for more details.
----------------------------


Could you please revisit?


Thanks.

Code:
sub {

my ($limit,$sort_order,$cat_id) = (shift,shift,shift);
my @queries = @_;

$sort_order ||= "Title ASC";

my $tbl = $DB->table('Links');

if ($limit) {
$tbl->select_options(qq|ORDER BY $sort_order LIMIT $limit|);
} else {
$tbl->select_options(qq|ORDER BY $sort_order|);
}

my $cond = new GT::SQL::Condition;

foreach (@queries) {
my ($field,$operator,$val) = split /::/;
$cond->add($field,$operator,$val);
}
$cond->bool("AND");

my $sth = $tbl->select( $cond, { 'CatLinks.CategoryID' => $cat_id } ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {

$hit = Links::SiteHTML::tags('link', $hit);
push @loop, $hit;
}

return { cond_loop_link => \@loop }


}
Subject Author Views Date
Thread Links Custom Sort - part 2 (For Alex) AMIXIMA 2846 Mar 18, 2012, 11:20 AM
Thread Re: [AMIXIMA] Links Custom Sort - part 2 (For Alex)
AMIXIMA 2768 Mar 18, 2012, 1:08 PM
Thread Re: [AMIXIMA] Links Custom Sort - part 2 (For Alex)
Andy 2761 Mar 19, 2012, 1:54 AM
Post Re: [Andy] Links Custom Sort - part 2 (For Alex)
AMIXIMA 2753 Mar 19, 2012, 7:31 AM