[Koha-cvs] CVS: koha/html-template Search.pm,1.3,1.4
Andrew Arensburger
arensb at users.sourceforge.net
Sat Oct 5 12:04:11 CEST 2002
Update of /cvsroot/koha/koha/html-template
In directory usw-pr-cvs1:/tmp/cvs-serv27288/html-template
Modified Files:
Search.pm
Log Message:
Merged with arensb-context branch: use C4::Context->dbh instead of
&C4Connect, and generally prefer C4::Context over C4::Database.
Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/html-template/Search.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Search.pm 14 Aug 2002 18:12:53 -0000 1.3
--- Search.pm 5 Oct 2002 10:04:09 -0000 1.4
***************
*** 22,29 ****
# Suite 330, Boston, MA 02111-1307 USA
use strict;
require Exporter;
use DBI;
! use C4::Database;
use C4::Reserves2;
use Set::Scalar;
--- 22,32 ----
# Suite 330, Boston, MA 02111-1307 USA
+ # FIXME - This file is very similar to C4/Search.pm (and they both
+ # claim to be package C4::Search). So shouldn't this file be nuked?
+
use strict;
require Exporter;
use DBI;
! use C4::Context;
use C4::Reserves2;
use Set::Scalar;
***************
*** 77,81 ****
sub findguarantees{
my ($bornum)=@_;
! my $dbh=C4Connect;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
--- 80,84 ----
sub findguarantees{
my ($bornum)=@_;
! my $dbh = C4::Context->dbh;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
***************
*** 89,98 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@dat);
}
sub findguarantor{
my ($bornum)=@_;
! my $dbh=C4Connect;
my $query="select guarantor from borrowers where
borrowernumber='$bornum'";
--- 92,100 ----
}
$sth->finish;
return($i,\@dat);
}
sub findguarantor{
my ($bornum)=@_;
! my $dbh = C4::Context->dbh;
my $query="select guarantor from borrowers where
borrowernumber='$bornum'";
***************
*** 107,111 ****
$data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 109,112 ----
***************
*** 113,117 ****
sub systemprefs {
my %systemprefs;
! my $dbh=C4Connect;
my $sth=$dbh->prepare("select variable,value from systempreferences");
$sth->execute;
--- 114,118 ----
sub systemprefs {
my %systemprefs;
! my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select variable,value from systempreferences");
$sth->execute;
***************
*** 120,129 ****
}
$sth->finish;
- $dbh->disconnect;
return(%systemprefs);
}
sub NewBorrowerNumber {
! my $dbh=C4Connect;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
--- 121,129 ----
}
$sth->finish;
return(%systemprefs);
}
sub NewBorrowerNumber {
! my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
***************
*** 131,135 ****
$sth->finish;
$data->{'max(borrowernumber)'}++;
- $dbh->disconnect;
return($data->{'max(borrowernumber)'});
}
--- 131,134 ----
***************
*** 138,142 ****
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)=@_;
! my $dbh = &C4Connect;
my $resulthash;
$search->{'keyword'}=~ s/ +$//;
--- 137,141 ----
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)=@_;
! my $dbh = C4::Context->dbh;
my $resulthash;
$search->{'keyword'}=~ s/ +$//;
***************
*** 307,311 ****
}
}
- $dbh->disconnect;
#$count=$i;
--- 306,309 ----
***************
*** 315,319 ****
sub KeywordSearch2 {
my ($env,$type,$search,$num,$offset)=@_;
! my $dbh = &C4Connect;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
--- 313,317 ----
sub KeywordSearch2 {
my ($env,$type,$search,$num,$offset)=@_;
! my $dbh = C4::Context->dbh;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
***************
*** 455,459 ****
}
$sth->finish;
- $dbh->disconnect;
# $i--;
# $i++;
--- 453,456 ----
***************
*** 463,467 ****
sub CatSearch {
my ($env,$type,$search,$num,$offset)=@_;
! my $dbh = &C4Connect;
my $query = '';
my @results;
--- 460,464 ----
sub CatSearch {
my ($env,$type,$search,$num,$offset)=@_;
! my $dbh = C4::Context->dbh;
my $query = '';
my @results;
***************
*** 717,721 ****
sub subsearch {
my ($env,$subject)=@_;
! my $dbh=C4Connect();
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
--- 714,718 ----
sub subsearch {
my ($env,$subject)=@_;
! my $dbh = C4::Context->dbh;
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
***************
*** 732,736 ****
}
$sth->finish;
- $dbh->disconnect;
return(@results);
}
--- 729,732 ----
***************
*** 739,743 ****
sub ItemInfo {
my ($env,$biblionumber,$type)=@_;
! my $dbh = &C4Connect;
my $query="Select * from items,biblio,biblioitems,branches
where (items.biblioitemnumber = biblioitems.biblioitemnumber)
--- 735,739 ----
sub ItemInfo {
my ($env,$biblionumber,$type)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from items,biblio,biblioitems,branches
where (items.biblioitemnumber = biblioitems.biblioitemnumber)
***************
*** 815,819 ****
$sth2->finish;
- $dbh->disconnect;
return(@results);
}
--- 811,814 ----
***************
*** 822,826 ****
my ($env,$biblionumber)=@_;
#debug_msg($env,"GetItems");
! my $dbh = &C4Connect;
my $query = "Select * from biblioitems where (biblionumber = $biblionumber)";
#debug_msg($env,$query);
--- 817,821 ----
my ($env,$biblionumber)=@_;
#debug_msg($env,"GetItems");
! my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where (biblionumber = $biblionumber)";
#debug_msg($env,$query);
***************
*** 855,859 ****
}
$sth->finish;
- $dbh->disconnect;
return(@results);
}
--- 850,853 ----
***************
*** 861,865 ****
sub itemdata {
my ($barcode)=@_;
! my $dbh=C4Connect;
my $query="Select * from items,biblioitems where barcode='$barcode'
and items.biblioitemnumber=biblioitems.biblioitemnumber";
--- 855,859 ----
sub itemdata {
my ($barcode)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from items,biblioitems where barcode='$barcode'
and items.biblioitemnumber=biblioitems.biblioitemnumber";
***************
*** 868,872 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 862,865 ----
***************
*** 874,878 ****
sub bibdata {
my ($bibnum,$type)=@_;
! my $dbh=C4Connect;
my $query="Select *,biblio.notes
from biblio,biblioitems
--- 867,871 ----
sub bibdata {
my ($bibnum,$type)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select *,biblio.notes
from biblio,biblioitems
***************
*** 894,898 ****
}
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 887,890 ----
***************
*** 900,904 ****
sub bibitemdata {
my ($bibitem)=@_;
! my $dbh=C4Connect;
my $query="Select *,biblioitems.notes as bnotes from biblio,biblioitems,itemtypes where biblio.biblionumber=
biblioitems.biblionumber and biblioitemnumber=$bibitem and
--- 892,896 ----
sub bibitemdata {
my ($bibitem)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select *,biblioitems.notes as bnotes from biblio,biblioitems,itemtypes where biblio.biblionumber=
biblioitems.biblionumber and biblioitemnumber=$bibitem and
***************
*** 908,912 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 900,903 ----
***************
*** 914,918 ****
sub subject {
my ($bibnum)=@_;
! my $dbh=C4Connect;
my $query="Select * from bibliosubject where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
--- 905,909 ----
sub subject {
my ($bibnum)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubject where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
***************
*** 925,929 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
--- 916,919 ----
***************
*** 931,935 ****
sub addauthor {
my ($bibnum)=@_;
! my $dbh=C4Connect;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
--- 921,925 ----
sub addauthor {
my ($bibnum)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
***************
*** 942,946 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
--- 932,935 ----
***************
*** 948,952 ****
sub subtitle {
my ($bibnum)=@_;
! my $dbh=C4Connect;
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
--- 937,941 ----
sub subtitle {
my ($bibnum)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
***************
*** 959,963 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
--- 948,951 ----
***************
*** 967,971 ****
sub itemissues {
my ($bibitem,$biblio)=@_;
! my $dbh=C4Connect;
my $query="Select * from items where
items.biblioitemnumber='$bibitem'";
--- 955,959 ----
sub itemissues {
my ($bibitem,$biblio)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from items where
items.biblioitemnumber='$bibitem'";
***************
*** 1007,1011 ****
}
$sth->finish;
- $dbh->disconnect;
return(@results);
}
--- 995,998 ----
***************
*** 1013,1017 ****
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
! $dbh=C4Connect;
my $query="Select * from biblio,items,biblioitems
where items.itemnumber = '$itemnumber'
--- 1000,1004 ----
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
! $dbh = C4::Context->dbh;
my $query="Select * from biblio,items,biblioitems
where items.itemnumber = '$itemnumber'
***************
*** 1022,1026 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 1009,1012 ----
***************
*** 1030,1034 ****
sub BornameSearch {
my ($env,$searchstring,$type)=@_;
! my $dbh = &C4Connect;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
--- 1016,1020 ----
sub BornameSearch {
my ($env,$searchstring,$type)=@_;
! my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
***************
*** 1056,1060 ****
# $sth->execute;
$sth->finish;
- $dbh->disconnect;
return ($cnt,\@results);
}
--- 1042,1045 ----
***************
*** 1063,1067 ****
my ($cardnumber,$bornum)=@_;
$cardnumber = uc $cardnumber;
! my $dbh=C4Connect;
my $query;
if ($bornum eq ''){
--- 1048,1052 ----
my ($cardnumber,$bornum)=@_;
$cardnumber = uc $cardnumber;
! my $dbh = C4::Context->dbh;
my $query;
if ($bornum eq ''){
***************
*** 1074,1078 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 1059,1062 ----
***************
*** 1080,1084 ****
sub borrissues {
my ($bornum)=@_;
! my $dbh=C4Connect;
my $query;
$query="Select * from issues,biblio,items where borrowernumber='$bornum' and
--- 1064,1068 ----
sub borrissues {
my ($bornum)=@_;
! my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items where borrowernumber='$bornum' and
***************
*** 1095,1099 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@result);
}
--- 1079,1082 ----
***************
*** 1101,1105 ****
sub allissues {
my ($bornum,$order,$limit)=@_;
! my $dbh=C4Connect;
my $query;
$query="Select * from issues,biblio,items,biblioitems
--- 1084,1088 ----
sub allissues {
my ($bornum,$order,$limit)=@_;
! my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items,biblioitems
***************
*** 1121,1125 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@result);
}
--- 1104,1107 ----
***************
*** 1127,1131 ****
sub borrdata2 {
my ($env,$bornum)=@_;
! my $dbh=C4Connect;
my $query="Select count(*) from issues where borrowernumber='$bornum' and
returndate is NULL";
--- 1109,1113 ----
sub borrdata2 {
my ($env,$bornum)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select count(*) from issues where borrowernumber='$bornum' and
returndate is NULL";
***************
*** 1144,1148 ****
my $data3=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data2->{'count(*)'},$data->{'count(*)'},$data3->{'sum(amountoutstanding)'});
--- 1126,1129 ----
***************
*** 1152,1156 ****
sub getboracctrecord {
my ($env,$params) = @_;
! my $dbh=C4Connect;
my @acctlines;
my $numlines=0;
--- 1133,1137 ----
sub getboracctrecord {
my ($env,$params) = @_;
! my $dbh = C4::Context->dbh;
my @acctlines;
my $numlines=0;
***************
*** 1175,1179 ****
}
$sth->finish;
- $dbh->disconnect;
return ($numlines,\@acctlines,$total);
}
--- 1156,1159 ----
***************
*** 1181,1185 ****
sub itemcount {
my ($env,$bibnum,$type)=@_;
! my $dbh=C4Connect;
my $query="Select * from items where
biblionumber=$bibnum ";
--- 1161,1165 ----
sub itemcount {
my ($env,$bibnum,$type)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from items where
biblionumber=$bibnum ";
***************
*** 1241,1245 ****
$sth2->finish;
$sth->finish;
- $dbh->disconnect;
return ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount);
}
--- 1221,1224 ----
***************
*** 1247,1251 ****
sub ItemType {
my ($type)=@_;
! my $dbh=C4Connect;
my $query="select description from itemtypes where itemtype='$type'";
my $sth=$dbh->prepare($query);
--- 1226,1230 ----
sub ItemType {
my ($type)=@_;
! my $dbh = C4::Context->dbh;
my $query="select description from itemtypes where itemtype='$type'";
my $sth=$dbh->prepare($query);
***************
*** 1253,1257 ****
my $dat=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return ($dat->{'description'});
}
--- 1232,1235 ----
***************
*** 1259,1263 ****
sub bibitems {
my ($bibnum)=@_;
! my $dbh=C4Connect;
my $query="Select * from biblioitems,itemtypes,items where
biblioitems.biblionumber='$bibnum' and biblioitems.itemtype=itemtypes.itemtype and
--- 1237,1241 ----
sub bibitems {
my ($bibnum)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems,itemtypes,items where
biblioitems.biblionumber='$bibnum' and biblioitems.itemtype=itemtypes.itemtype and
***************
*** 1273,1277 ****
}
$sth->finish;
- $dbh->disconnect;
return($i, at results);
}
--- 1251,1254 ----
***************
*** 1279,1283 ****
sub barcodes{
my ($biblioitemnumber)=@_;
! my $dbh=C4Connect;
my $query="Select barcode from items where
biblioitemnumber='$biblioitemnumber'";
--- 1256,1260 ----
sub barcodes{
my ($biblioitemnumber)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select barcode from items where
biblioitemnumber='$biblioitemnumber'";
***************
*** 1291,1295 ****
}
$sth->finish;
- $dbh->disconnect;
return(@barcodes);
--- 1268,1271 ----
More information about the Koha-cvs
mailing list