From 8ad078f97e9aefafb583c2a7ba023f3f9ba92d13 Mon Sep 17 00:00:00 2001 From: rangi Date: Mon, 26 Nov 2001 04:33:42 +0000 Subject: [PATCH] Fixing a bug in keyword search was duplicating results --- C4/Search.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 2277dc7977..4065088e72 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -316,7 +316,8 @@ sub KeywordSearch { $sth->execute; $i=0; while (my $data=$sth->fetchrow_hashref){ - my $sti=$dbh->prepare("select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'}"); + my $sti=$dbh->prepare("select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'} + "); $sti->execute; my ($dewey, $subclass) = $sti->fetchrow; $dewey=~s/\.*0*$//; @@ -329,11 +330,12 @@ sub KeywordSearch { } $sth->finish; $sth=$dbh->prepare("Select biblionumber from bibliosubject where subject - like '%$search->{'keyword'}%'"); + like '%$search->{'keyword'}%' group by biblionumber"); $sth->execute; while (my $data=$sth->fetchrow_hashref){ $query="Select * from biblio,biblioitems where - biblio.biblionumber=$data->{'biblionumber'} and biblio.biblionumber=biblioitems.biblionumber"; + biblio.biblionumber=$data->{'biblionumber'} and biblio.biblionumber=biblioitems.biblionumber + group by biblio.biblionumber"; if ($search->{'class'} ne ''){ my @temp=split(/\|/,$search->{'class'}); my $count=@temp; @@ -347,7 +349,13 @@ sub KeywordSearch { $sth2->execute; # print $query; while (my $data2=$sth2->fetchrow_hashref){ - $results[$i]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}"; + my $dewey= $data2->{'dewey'}; + my $subclass=$data2->{'subclass'}; + $dewey=~s/\.*0*$//; + ($dewey == 0) && ($dewey=''); + ($dewey) && ($dewey.=" $subclass") ; +# $sti->finish; + $results[$i]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey"; # print $results[$i]; $i++; } -- 2.39.2