[Koha-patches] [PATCH] Improving Research page when searching an existing record

Henri-Damien LAURENT henridamien at koha-fr.org
Thu Apr 24 09:59:18 CEST 2008


- ISBN was not sanitized
- research was only on title starting with exact expression :
Now, though it is a bit slower, it searches all the words in title OR author field
Problem still is that if user mixes author and title information in the box, the search will fail.

I suggested that we could have a single page with both z3950 and breeding search So that we would have a 3 or for box search system
And would be able to have all the possible results more easily. This could be achieved via reloading the page OR via AJAX features on import breeding.
---
 C4/Breeding.pm |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/C4/Breeding.pm b/C4/Breeding.pm
index 79f2e2f..b73fb6f 100644
--- a/C4/Breeding.pm
+++ b/C4/Breeding.pm
@@ -110,7 +110,7 @@ sub ImportBreeding {
             # overwrite or ignore depending on user choice
             # drop every "special" char : spaces, - ...
             $oldbiblio->{isbn} =~ s/\(.*$//;
-            $oldbiblio->{isbn} =~ tr/ -_//;
+            $oldbiblio->{isbn} =~ s/[ -_]//;
             $oldbiblio->{isbn} = uc $oldbiblio->{isbn}; 
             # search if biblio exists
             my $biblioitemnumber;
@@ -187,8 +187,18 @@ sub BreedingSearch {
     } else {
         @bind=();
         if ($title) {
-            $query .= "title like ?";
-            push(@bind,"$title%");
+	    my @words = split /[\'\s]/, $title; 
+            @bind= map {"%".$_."%"} @words;
+            if (scalar(@bind)>0) {
+	       $query.="( ";
+               $query .= "title like ? AND " x scalar(@bind);
+               $query =~ s/ AND $//;
+	       $query .= ") OR (";
+               $query .= "author like ? AND " x scalar(@bind);
+               $query =~ s/ AND $//;
+	       $query.=" )";
+	    }
+	    @bind=(@bind, at bind);
         }
         if ($title && $isbn) {
             $query .= " and ";
@@ -198,6 +208,7 @@ sub BreedingSearch {
             push(@bind,"$isbn%");
         }
     }
+    warn $query;
     $sth   = $dbh->prepare($query);
     $sth->execute(@bind);
     while (my $data = $sth->fetchrow_hashref) {
-- 
1.5.3.2




More information about the Koha-patches mailing list