Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Paging DBIx::FullTextSearch results

by stew (Scribe)
on Nov 27, 2002 at 10:41 UTC ( [id://216050]=perlquestion: print w/replies, xml ) Need Help??

stew has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have built an index of a MySQL database using DBIx::FullTextSearch. I would like to provide previous/next and paged links. I have had a look at HTML::Pager and as I am also using HTML::Template this seems like the ideal solution.

I have poured over the documentation several times though I have to admit I'm no further forward. My first problem is DBIx::FullTextSearch only gives a resource id so I have to use this to query MySQL again and get some more interesting data such as resource title to show to the user. I can then put this into a hash and put this into a HTML::Template loop.

My first question then is.... which set of data do I apply HTML::Pager to the @files or @rows ? (see code below).

#!/usr/bin/perl use CGI qw(param); use DBIx::FullTextSearch; use DBIx::FullTextSearch::StopList; use DBI; use HTML::Template; my $dbh = DBI->connect('dbi:mysql:xxxx','xxxx','xxxxxx'); my $search = param("search"); my $fts = DBIx::FullTextSearch->open($dbh, 'fts_xxxx'); my @files = $fts->search($search); if (@files) { foreach $filename(@files){ $filename = substr($filename,0,-4); $sth = $dbh->prepare("SELECT id, title FROM resource WHERE id = +?"); $sth->execute($filename); while ($ref = $sth->fetchrow_hashref()){ $title = $ref->{title}; $id = $ref->{id}; push @rows, { ID => $id, TITLE => $title }; } } } my $template = HTML::Template->new(filename => 'pg_search.tmpl'); $template->param(TAB_BG_MAIN => "#0B5875"); $template->param(TAB_BG_HEAD => "#6180BA"); $template->param(SEARCH => $search); $template->param(ROWS => \@rows); print "Content-type: text/html\n\n"; print $template->output;


I'm not 100% about the call back routine mentioned in the docs and how I'm going to pass this to HTML::Template but if anybody can point me in the right direction I would be most grateful.

Many thanks

./stew

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://216050]
Approved by adrianh
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found