From 4e3888e2ec49f9a0572b4a16140a02223a6ad275 Mon Sep 17 00:00:00 2001 From: wolfpac444 Date: Fri, 21 Feb 2003 02:25:03 +0000 Subject: [PATCH] Fixed the subject search. --- C4/Search.pm | 18 ++++++------------ opac/opac-searchresults.pl | 3 ++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index eb4cb961a8..e9eb193bbb 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1001,20 +1001,14 @@ sub CatSearch { } } if ($type eq 'subject'){ - # FIXME - Subject search is badly broken. The query defined by - # $query returns a single item (the subject), but later code - # expects a ref-to-hash with all sorts of stuff in it. - # Also, the count of items (biblios?) with the given subject is - # wrong. - my @key=split(' ',$search->{'subject'}); my $count=@key; my $i=1; - $query="select distinct(subject) from bibliosubject where( subject like - '$key[0]%' or subject like '% $key[0]%' or subject like '% $key[0]' or subject like '%($key[0])%')"; - while ($i<$count){ - $query.=" and (subject like '$key[$i]%' or subject like '% $key[$i]%' - or subject like '% $key[$i]' + $query="select * from bibliosubject, biblioitems where +(bibliosubject.biblionumber = biblioitems.biblionumber) and ( subject like +'$key[0]%' or subject like '% $key[0]%' or subject like '% $key[0]' or subject +like '%($key[0])%')"; while ($i<$count){ $query.=" and (subject like +'$key[$i]%' or subject like '% $key[$i]%' or subject like '% $key[$i]' or subject like '%($key[$i])%')"; $i++; } @@ -1180,7 +1174,7 @@ sub subsearch { # print $query; my @results; while (my $data=$sth->fetchrow_hashref){ - $results[$i]="$data->{'title'}\t$data->{'author'}\t$data->{'biblionumber'}"; + push @results, $data; $i++; } $sth->finish; diff --git a/opac/opac-searchresults.pl b/opac/opac-searchresults.pl index eec82593cd..b30c718900 100755 --- a/opac/opac-searchresults.pl +++ b/opac/opac-searchresults.pl @@ -68,7 +68,8 @@ my $count; my $startfrom = $query->param('startfrom'); my $subjectitems=$query->param('subjectitems'); if ($subjectitems) { - @results = subsearch($env,$subjectitems, $number_of_results, $startfrom); + #@results = subsearch($env,$subjectitems, $number_of_results, $startfrom); + @results = subsearch($enc, $subjectitems); $count = $#results+1; } else { ($count, @results) = catalogsearch($env,'',\%search,$number_of_results,$startfrom); -- 2.39.5