[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Search.pm,1.29,1.30
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/C4 Search.pm,1.29,1.30 |
Date: |
Fri, 28 Jun 2002 01:53:53 -0700 |
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv28633/C4
Modified Files:
Search.pm
Log Message:
merging 1-2 and main.
Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** Search.pm 6 Jun 2002 04:15:18 -0000 1.29
--- Search.pm 28 Jun 2002 08:53:51 -0000 1.30
***************
*** 1,6 ****
! package C4::Search; #asummes C4/Search
!
! #requires DBI.pm to be installed
! #uses DBD:Pg
use strict;
--- 1,3 ----
! package C4::Search; #assumes C4/Search
use strict;
***************
*** 23,59 ****
&addauthor &bibitems &barcodes &findguarantees &allissues &systemprefs
&findguarantor &getwebsites &getwebbiblioitems &catalogsearch itemcount2);
- %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
-
- # your exported package globals go here,
- # as well as any optionally exported functions
-
- @EXPORT_OK = qw($Var1 %Hashit);
-
-
- # non-exported package globals go here
- use vars qw(@more $stuff);
-
- # initalize package globals, first exported ones
-
- my $Var1 = '';
- my %Hashit = ();
-
- # then the others (which are still accessible as $Some::Module::stuff)
- my $stuff = '';
- my @more = ();
-
- # all file-scoped lexicals must be created before
- # the functions below that use them.
-
- # file-private lexicals go here
- my $priv_var = '';
- my %secret_hash = ();
-
- # here's a file-private function as a closure,
- # callable as &$priv_func; it cannot be prototyped.
- my $priv_func = sub {
- # stuff goes here.
- };
-
# make all your functions, whether exported or not;
sub findguarantees{
--- 20,23 ----
***************
*** 124,128 ****
# }
my ($count,@results);
! print STDERR "Doing a search \n";
if ($search->{'itemnumber'} ne '' || $search->{'isbn'} ne ''){
print STDERR "Doing a precise search\n";
--- 88,92 ----
# }
my ($count,@results);
! # print STDERR "Doing a search \n";
if ($search->{'itemnumber'} ne '' || $search->{'isbn'} ne ''){
print STDERR "Doing a precise search\n";
***************
*** 186,190 ****
my $sth=$dbh->prepare($query);
$sth->execute;
! my $i=0;
while (my @res=$sth->fetchrow_array){
$results[$i]=$res[0];
--- 150,154 ----
my $sth=$dbh->prepare($query);
$sth->execute;
! $i=0;
while (my @res=$sth->fetchrow_array){
$results[$i]=$res[0];
***************
*** 343,346 ****
--- 307,460 ----
}
+ sub KeywordSearch2 {
+ my ($env,$type,$search,$num,$offset)address@hidden;
+ my $dbh = &C4Connect;
+ $search->{'keyword'}=~ s/ +$//;
+ $search->{'keyword'}=~ s/'/\\'/;
+ my @key=split(' ',$search->{'keyword'});
+ my address@hidden;
+ my $i=1;
+ 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]%')";
+ $i++;
+ }
+ $query.= ") or ((subtitle like '$key[0]%' or subtitle like '% $key[0]%')";
+ for ($i=1;$i<$count;$i++){
+ $query.= " and (subtitle like '$key[$i]%' or subtitle like '%
$key[$i]%')";
+ }
+ $query.= ") or ((seriestitle like '$key[0]%' or seriestitle like '%
$key[0]%')";
+ for ($i=1;$i<$count;$i++){
+ $query.=" and (seriestitle like '$key[$i]%' or seriestitle like '%
$key[$i]%')";
+ }
+ $query.= ") or ((biblio.notes like '$key[0]%' or biblio.notes like '%
$key[0]%')";
+ for ($i=1;$i<$count;$i++){
+ $query.=" and (biblio.notes like '$key[$i]%' or biblio.notes like '%
$key[$i]%')";
+ }
+ $query.= ") or ((biblioitems.notes like '$key[0]%' or biblioitems.notes
like '% $key[0]%')";
+ for ($i=1;$i<$count;$i++){
+ $query.=" and (biblioitems.notes like '$key[$i]%' or biblioitems.notes
like '% $key[$i]%')";
+ }
+ if ($search->{'keyword'} =~ /new zealand/i){
+ $query.= "or (title like 'nz%' or title like '% nz %' or title like '%
nz' or subtitle like 'nz%'
+ or subtitle like '% nz %' or subtitle like '% nz' or author like 'nz %'
+ or author like '% nz %' or author like '% nz')"
+ }
+ if ($search->{'keyword'} eq 'nz' || $search->{'keyword'} eq 'NZ' ||
+ $search->{'keyword'} =~ /nz /i || $search->{'keyword'} =~ / nz /i ||
+ $search->{'keyword'} =~ / nz/i){
+ $query.= "or (title like 'new zealand%' or title like '% new zealand %'
+ or title like '% new zealand' or subtitle like 'new zealand%' or
+ subtitle like '% new zealand %'
+ or subtitle like '% new zealand' or author like 'new zealand%'
+ or author like '% new zealand %' or author like '% new zealand' or
+ seriestitle like 'new zealand%' or seriestitle like '% new zealand %'
+ or seriestitle like '% new zealand')"
+ }
+ $query=$query."))";
+ if ($search->{'class'} ne ''){
+ my @temp=split(/\|/,$search->{'class'});
+ my address@hidden;
+ $query.= "and ( itemtype='$temp[0]'";
+ for (my $i=1;$i<$count;$i++){
+ $query.=" or itemtype='$temp[$i]'";
+ }
+ $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);
+ $sth->execute;
+ $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];
+ $i++;
+ }
+ $sth->finish;
+ $sth=$dbh->prepare("Select biblionumber from bibliosubject where subject
+ 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 ";
+ if ($search->{'class'} ne ''){
+ my @temp=split(/\|/,$search->{'class'});
+ my address@hidden;
+ $query.= " and ( itemtype='$temp[0]'";
+ for (my $i=1;$i<$count;$i++){
+ $query.=" or itemtype='$temp[$i]'";
+ }
+ $query.=")";
+
+ }
+ if ($search->{'dewey'} ne ''){
+ $query.= "and (dewey like '$search->{'dewey'}%') ";
+ }
+ my $sth2=$dbh->prepare($query);
+ $sth2->execute;
+ # print $query;
+ while (my $data2=$sth2->fetchrow_hashref){
+ 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++;
+ }
+ $sth2->finish;
+ }
+ my $i2=1;
+ @results=sort @results;
+ my @res;
+ address@hidden;
+ $i=1;
+ if ($count > 0){
+ $res[0]=$results[0];
+ }
+ while ($i2 < $count){
+ if ($results[$i2] ne $res[$i-1]){
+ $res[$i]=$results[$i2];
+ $i++;
+ }
+ $i2++;
+ }
+ $i2=0;
+ my @res2;
+ address@hidden;
+ while ($i2 < $num && $i2 < $count){
+ $res2[$i2]=$res[$i2+$offset];
+ # print $res2[$i2];
+ $i2++;
+ }
+ $sth->finish;
+ $dbh->disconnect;
+ # $i--;
+ # $i++;
+ return($i,@res2);
+ }
+
sub CatSearch {
my ($env,$type,$search,$num,$offset)address@hidden;
***************
*** 479,484 ****
$query.= "Select * from biblio where abstract like
'%$search->{'abstract'}%'";
}
-
-
$query .=" group by biblio.biblionumber";
}
--- 593,596 ----
***************
*** 518,522 ****
my $query1 = "select * from biblioitems where isbn='$search2'";
my $sth1=$dbh->prepare($query1);
! print STDERR "$query1\n";
$sth1->execute;
my $i2=0;
--- 630,634 ----
my $query1 = "select * from biblioitems where isbn='$search2'";
my $sth1=$dbh->prepare($query1);
! # print STDERR "$query1\n";
$sth1->execute;
my $i2=0;
***************
*** 553,557 ****
}
}
! print STDERR "$query\n";
my $sth=$dbh->prepare($query);
$sth->execute;
--- 665,669 ----
}
}
! #print STDERR "$query\n";
my $sth=$dbh->prepare($query);
$sth->execute;
***************
*** 579,583 ****
$query.= " and (publishercode like '%$search->{'publisher'}%')";
}
! print STDERR "$query\n";
my $sti=$dbh->prepare($query);
$sti->execute;
--- 691,695 ----
$query.= " and (publishercode like '%$search->{'publisher'}%')";
}
! #print STDERR "$query\n";
my $sti=$dbh->prepare($query);
$sti->execute;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Search.pm,1.29,1.30,
Paul POULAIN <=