[Koha-devel] CVS: koha/C4 Search.pm,1.10,1.11

Chris Cormack rangi at users.sourceforge.net
Tue Dec 11 18:32:02 CET 2001


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv5285/C4

Modified Files:
	Search.pm 
Log Message:
Added the facility to restrict a keyword search by dewey number


Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** Search.pm	2001/11/27 02:01:39	1.10
--- Search.pm	2001/12/12 02:31:28	1.11
***************
*** 262,268 ****
    my @results;
    my $query ="Select * from biblio,bibliosubtitle,biblioitems where
    biblio.biblionumber=bibliosubtitle.biblionumber and
-   biblioitems.biblionumber=biblio.biblionumber and
    (((title like '$key[0]%' or title like '% $key[0]%')";
    while ($i < $count){
      $query=$query." and (title like '$key[$i]%' or title like '% $key[$i]%')";
--- 262,269 ----
    my @results;
    my $query ="Select * from biblio,bibliosubtitle,biblioitems where
+   biblio.biblionumber=biblioitems.biblionumber and
    biblio.biblionumber=bibliosubtitle.biblionumber and
    (((title like '$key[0]%' or title like '% $key[0]%')";
+ 
    while ($i < $count){
      $query=$query." and (title like '$key[$i]%' or title like '% $key[$i]%')";
***************
*** 311,315 ****
    $query.=")"; 
    }
!    $query.="group by biblio.biblionumber order by author,title";
  #  print $query;
    my $sth=$dbh->prepare($query);
--- 312,320 ----
    $query.=")"; 
    }
!   if ($search->{'dewey'} ne ''){
!     $query.= "and (dewey like '$search->{'dewey'}%') ";
!   }
!    $query.="group by biblio.biblionumber";
!    #$query.=" order by author,title";
  #  print $query;
    my $sth=$dbh->prepare($query);
***************
*** 317,328 ****
    $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     my $sti=$dbh->prepare("select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'}
!     ");
!     $sti->execute;
!     my ($dewey, $subclass) = $sti->fetchrow;
      $dewey=~s/\.*0*$//;
      ($dewey == 0) && ($dewey='');
      ($dewey) && ($dewey.=" $subclass");
!     $sti->finish;
      $results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey";
  #      print $results[$i];
--- 322,335 ----
    $i=0;
    while (my $data=$sth->fetchrow_hashref){
! #    my $sti=$dbh->prepare("select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'}
! #    ");
! #    $sti->execute;
! #    my ($dewey, $subclass) = $sti->fetchrow;
!     my $dewey=$data->{'dewey'};
!     my $subclass=$data->{'subclass'};
      $dewey=~s/\.*0*$//;
      ($dewey == 0) && ($dewey='');
      ($dewey) && ($dewey.=" $subclass");
! #    $sti->finish;
      $results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey";
  #      print $results[$i];
***************
*** 345,348 ****
--- 352,359 ----
        }
        $query.=")"; 
+       
+     }
+     if ($search->{'dewey'} ne ''){
+       $query.= "and (dewey like '$search->{'dewey'}%') ";
      }
      my $sth2=$dbh->prepare($query);





More information about the Koha-devel mailing list