koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Search.pm,1.69,1.70


From: Jerome Vizcaino
Subject: [Koha-cvs] CVS: koha/C4 Search.pm,1.69,1.70
Date: Thu, 19 Jun 2003 09:14:32 -0700

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv5539

Modified Files:
        Search.pm 
Log Message:

bugfix for #499
The BornameSearch function now uses the $type parameter
Single and advanced search methods implemented.
Advanced is the old version.
Single only looks for $member% in surnames.


Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -r1.69 -r1.70
*** Search.pm   17 Jun 2003 11:21:13 -0000      1.69
--- Search.pm   19 Jun 2003 16:14:30 -0000      1.70
***************
*** 1722,1726 ****
  Looks up patrons (borrowers) by name.
  
! C<$env> and C<$type> are ignored.
  
  C<$searchstring> is a space-separated list of search terms. Each term
--- 1722,1728 ----
  Looks up patrons (borrowers) by name.
  
! C<$env> is ignored.
! 
! BUGFIX 499: C<$type> is now used to determine
  
  C<$searchstring> is a space-separated list of search terms. Each term
***************
*** 1742,1769 ****
        $searchstring=~ s/\,//g;
        $searchstring=~ s/\'/\\\'/g;
!       my @data=split(' ',$searchstring);
!       my address@hidden;
!       my $query="Select * from borrowers
!       where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\"
!       or firstname  like \"$data[0]%\" or firstname like \"% $data[0]%\"
!       or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\")
!       ";
!       for (my $i=1;$i<$count;$i++){
!       $query=$query." and (surname like \"$data[$i]%\" or surname like \"% 
$data[$i]%\"
!       or firstname  like \"$data[$i]%\" or firstname like \"% $data[$i]%\"
!       or othernames like \"$data[$i]%\" or othernames like \"% $data[$i]%\")";
!                               # FIXME - .= <<EOT;
        }
!       $query=$query.") or cardnumber = \"$searchstring\"
!       order by surname,firstname";
!                               # FIXME - .= <<EOT;
!       #  print $query,"\n";
        my $sth=$dbh->prepare($query);
        $sth->execute;
        my @results;
!       my $cnt=0;
        while (my $data=$sth->fetchrow_hashref){
        push(@results,$data);
-       $cnt ++;
        }
        #  $sth->execute;
--- 1744,1779 ----
        $searchstring=~ s/\,//g;
        $searchstring=~ s/\'/\\\'/g;
!       my $query = ""; my $count; my @data;
! 
!       if($type eq "simple")   # simple search for one letter only
!       {
!               $query="Select * from borrowers where surname like 
\"$searchstring%\" order by surname,firstname";
        }
!       else    # advanced search looking in surname, firstname and othernames
!       {
!               @data=split(' ',$searchstring);
!               address@hidden;
!               $query="Select * from borrowers
!               where ((surname like \"$data[0]%\" or surname like \"% 
$data[0]%\"
!               or firstname  like \"$data[0]%\" or firstname like \"% 
$data[0]%\"
!               or othernames like \"$data[0]%\" or othernames like \"% 
$data[0]%\")
!               ";
!               for (my $i=1;$i<$count;$i++){
!               $query=$query." and (surname like \"$data[$i]%\" or surname 
like \"% $data[$i]%\"
!               or firstname  like \"$data[$i]%\" or firstname like \"% 
$data[$i]%\"
!               or othernames like \"$data[$i]%\" or othernames like \"% 
$data[$i]%\")";
!                                       # FIXME - .= <<EOT;
!               }
!               $query=$query.") or cardnumber = \"$searchstring\"
!               order by surname,firstname";
!                                       # FIXME - .= <<EOT;
!       }
! 
        my $sth=$dbh->prepare($query);
        $sth->execute;
        my @results;
!       my $cnt=$sth->rows;
        while (my $data=$sth->fetchrow_hashref){
        push(@results,$data);
        }
        #  $sth->execute;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]