Hi Alex...
I tried your code in a simple cgi. And I got this error: "DBSQL (-580635): Fatal Error: Invalid argument type 'Term' passed to query"
My file is this way:
# Load required modules.
# ---------------------------------------------------
use strict;
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'admin';
use Links;
use Links: B_Utils;
use Links::HTML_Templates;
use Links: BSQL;
$|++;
my $in = new CGI;
print $in->header('text/html');
my $top5 = &top5 ($in);
print $top5;
sub top5 {
# -----------------------------------------------
# Returns a list of the top5 searched terms.
#
my ($in) = shift; # Needed for $in->escape
my $search = new Links: BSQL $LINKS{admin_root_path} . "/defs/Links.def";
# Let's get a list of the top 5 terms ordered by number of times someone
# has searched on them.
my $results = $search->query ( Term => '*', sb => 'Count', so => 'DESC', mh => 5 );
my $output = '';
my $term_q;
if ($search->hits) {
foreach my $term (@{$results}) {
$term = $search->array_to_hash($term);
$term_q = $in->escape($term);
print qq~
<a href="$LINKS{db_cgi_url}/busca.cgi?query=$term_q">$term</a>
~;
}
}
else {
$output = "Sorry no one has searched for anything yet.";
}
return $output;
}
I tried your code in a simple cgi. And I got this error: "DBSQL (-580635): Fatal Error: Invalid argument type 'Term' passed to query"
My file is this way:
Code:
#!/usr/local/bin/perl # Load required modules.
# ---------------------------------------------------
use strict;
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'admin';
use Links;
use Links: B_Utils;
use Links::HTML_Templates;
use Links: BSQL;
$|++;
my $in = new CGI;
print $in->header('text/html');
my $top5 = &top5 ($in);
print $top5;
sub top5 {
# -----------------------------------------------
# Returns a list of the top5 searched terms.
#
my ($in) = shift; # Needed for $in->escape
my $search = new Links: BSQL $LINKS{admin_root_path} . "/defs/Links.def";
# Let's get a list of the top 5 terms ordered by number of times someone
# has searched on them.
my $results = $search->query ( Term => '*', sb => 'Count', so => 'DESC', mh => 5 );
my $output = '';
my $term_q;
if ($search->hits) {
foreach my $term (@{$results}) {
$term = $search->array_to_hash($term);
$term_q = $in->escape($term);
print qq~
<a href="$LINKS{db_cgi_url}/busca.cgi?query=$term_q">$term</a>
~;
}
}
else {
$output = "Sorry no one has searched for anything yet.";
}
return $output;
}