[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Search.pm,1.40,1.41
From: |
Andrew Arensburger |
Subject: |
[Koha-cvs] CVS: koha/C4 Search.pm,1.40,1.41 |
Date: |
Sat, 05 Oct 2002 02:52:54 -0700 |
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv22675/C4
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/C4/Search.pm,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** Search.pm 3 Oct 2002 03:56:10 -0000 1.40
--- Search.pm 5 Oct 2002 09:52:52 -0000 1.41
***************
*** 22,27 ****
require Exporter;
use DBI;
! use C4::Database;
use C4::Reserves2;
use Set::Scalar;
--- 22,29 ----
require Exporter;
use DBI;
! use C4::Context;
use C4::Reserves2;
+ # FIXME - C4::Search uses C4::Reserves2, which uses C4::Search.
+ # So Perl complains that all of the functions here get redefined.
use Set::Scalar;
***************
*** 82,86 ****
sub findguarantees{
my ($bornum)address@hidden;
! my $dbh=C4Connect;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
--- 84,88 ----
sub findguarantees{
my ($bornum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
***************
*** 94,98 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,address@hidden);
}
--- 96,99 ----
***************
*** 116,120 ****
sub findguarantor{
my ($bornum)address@hidden;
! my $dbh=C4Connect;
my $query="select guarantor from borrowers where
borrowernumber='$bornum'";
--- 117,121 ----
sub findguarantor{
my ($bornum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="select guarantor from borrowers where
borrowernumber='$bornum'";
***************
*** 129,133 ****
$data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 130,133 ----
***************
*** 144,148 ****
sub systemprefs {
my %systemprefs;
! my $dbh=C4Connect;
my $sth=$dbh->prepare("select variable,value from systempreferences");
$sth->execute;
--- 144,148 ----
sub systemprefs {
my %systemprefs;
! my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select variable,value from systempreferences");
$sth->execute;
***************
*** 151,155 ****
}
$sth->finish;
- $dbh->disconnect;
return(%systemprefs);
}
--- 151,154 ----
***************
*** 164,168 ****
#'
sub NewBorrowerNumber {
! my $dbh=C4Connect;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
--- 163,167 ----
#'
sub NewBorrowerNumber {
! my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
***************
*** 170,174 ****
$sth->finish;
$data->{'max(borrowernumber)'}++;
- $dbh->disconnect;
return($data->{'max(borrowernumber)'});
}
--- 169,172 ----
***************
*** 216,220 ****
sub catalogsearch {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = C4Connect();
# foreach my $key (%$search){
# $search->{$key}=$dbh->quote($search->{$key});
--- 214,218 ----
sub catalogsearch {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = C4::Context->dbh;
# foreach my $key (%$search){
# $search->{$key}=$dbh->quote($search->{$key});
***************
*** 331,335 ****
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = &C4Connect;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
--- 329,333 ----
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = C4::Context->dbh;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
***************
*** 553,557 ****
}
}
- $dbh->disconnect;
#$count=$i;
--- 551,554 ----
***************
*** 561,565 ****
sub KeywordSearch2 {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = &C4Connect;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
--- 558,562 ----
sub KeywordSearch2 {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = C4::Context->dbh;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
***************
*** 703,707 ****
}
$sth->finish;
- $dbh->disconnect;
# $i--;
# $i++;
--- 700,703 ----
***************
*** 866,870 ****
sub CatSearch {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = &C4Connect;
my $query = '';
my @results;
--- 862,866 ----
sub CatSearch {
my ($env,$type,$search,$num,$offset)address@hidden;
! my $dbh = C4::Context->dbh;
my $query = '';
my @results;
***************
*** 1068,1071 ****
--- 1064,1068 ----
my $sth=$dbh->prepare($query);
$sth->execute;
+ # FIXME - There's already a $data in this scope.
my $data=$sth->fetchrow_hashref;
my ($dewey, $subclass) = ($data->{'dewey'}, $data->{'subclass'});
***************
*** 1181,1185 ****
sub subsearch {
my ($env,$subject)address@hidden;
! my $dbh=C4Connect();
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
--- 1178,1182 ----
sub subsearch {
my ($env,$subject)address@hidden;
! my $dbh = C4::Context->dbh;
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
***************
*** 1197,1201 ****
}
$sth->finish;
- $dbh->disconnect;
return(@results);
}
--- 1194,1197 ----
***************
*** 1249,1253 ****
sub ItemInfo {
my ($env,$biblionumber,$type) = @_;
! my $dbh = &C4Connect;
my $query = "SELECT * FROM items, biblio, biblioitems, itemtypes
WHERE items.biblionumber = ?
--- 1245,1249 ----
sub ItemInfo {
my ($env,$biblionumber,$type) = @_;
! my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM items, biblio, biblioitems, itemtypes
WHERE items.biblionumber = ?
***************
*** 1349,1353 ****
$sth2->finish;
- $dbh->disconnect;
return(@results);
}
--- 1345,1348 ----
***************
*** 1376,1380 ****
my ($env,$biblionumber)address@hidden;
#debug_msg($env,"GetItems");
! my $dbh = &C4Connect;
my $query = "Select * from biblioitems where (biblionumber =
$biblionumber)";
#debug_msg($env,$query);
--- 1371,1375 ----
my ($env,$biblionumber)address@hidden;
#debug_msg($env,"GetItems");
! my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where (biblionumber =
$biblionumber)";
#debug_msg($env,$query);
***************
*** 1409,1413 ****
}
$sth->finish;
- $dbh->disconnect;
return(@results);
}
--- 1404,1407 ----
***************
*** 1426,1430 ****
sub itemdata {
my ($barcode)address@hidden;
! my $dbh=C4Connect;
my $query="Select * from items,biblioitems where barcode='$barcode'
and items.biblioitemnumber=biblioitems.biblioitemnumber";
--- 1420,1424 ----
sub itemdata {
my ($barcode)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select * from items,biblioitems where barcode='$barcode'
and items.biblioitemnumber=biblioitems.biblioitemnumber";
***************
*** 1434,1438 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 1428,1431 ----
***************
*** 1460,1464 ****
sub bibdata {
my ($bibnum, $type) = @_;
! my $dbh = C4Connect;
my $query = "Select *, biblio.notes
from biblio, biblioitems
--- 1453,1457 ----
sub bibdata {
my ($bibnum, $type) = @_;
! my $dbh = C4::Context->dbh;
my $query = "Select *, biblio.notes
from biblio, biblioitems
***************
*** 1482,1486 ****
$sth->finish;
- $dbh->disconnect;
return($data);
} # sub bibdata
--- 1475,1478 ----
***************
*** 1499,1503 ****
sub bibitemdata {
my ($bibitem) = @_;
! my $dbh = C4Connect;
my $query = "Select *,biblioitems.notes as bnotes from biblio,
biblioitems,itemtypes
where biblio.biblionumber = biblioitems.biblionumber
--- 1491,1495 ----
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
***************
*** 1512,1516 ****
$sth->finish;
- $dbh->disconnect;
return($data);
} # sub bibitemdata
--- 1504,1507 ----
***************
*** 1529,1533 ****
sub subject {
my ($bibnum)address@hidden;
! my $dbh=C4Connect;
my $query="Select * from bibliosubject where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
--- 1520,1524 ----
sub subject {
my ($bibnum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubject where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
***************
*** 1540,1544 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,address@hidden);
}
--- 1531,1534 ----
***************
*** 1559,1563 ****
sub addauthor {
my ($bibnum)address@hidden;
! my $dbh=C4Connect;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
--- 1549,1553 ----
sub addauthor {
my ($bibnum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
***************
*** 1570,1574 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,address@hidden);
}
--- 1560,1563 ----
***************
*** 1588,1592 ****
sub subtitle {
my ($bibnum)address@hidden;
! my $dbh=C4Connect;
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
--- 1577,1581 ----
sub subtitle {
my ($bibnum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
***************
*** 1599,1603 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,address@hidden);
}
--- 1588,1591 ----
***************
*** 1649,1653 ****
sub itemissues {
my ($bibitem, $biblio)address@hidden;
! my $dbh = C4Connect;
my $query = "Select * from items where
items.biblioitemnumber = '$bibitem'";
--- 1637,1641 ----
sub itemissues {
my ($bibitem, $biblio)address@hidden;
! my $dbh = C4::Context->dbh;
my $query = "Select * from items where
items.biblioitemnumber = '$bibitem'";
***************
*** 1718,1722 ****
$sth->finish;
- $dbh->disconnect;
return(@results);
}
--- 1706,1709 ----
***************
*** 1738,1742 ****
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
! $dbh=C4Connect;
my $query="Select * from biblio,items,biblioitems
where items.itemnumber = '$itemnumber'
--- 1725,1729 ----
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
! $dbh = C4::Context->dbh;
my $query="Select * from biblio,items,biblioitems
where items.itemnumber = '$itemnumber'
***************
*** 1748,1752 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 1735,1738 ----
***************
*** 1775,1779 ****
sub BornameSearch {
my ($env,$searchstring,$type)address@hidden;
! my $dbh = &C4Connect;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
--- 1761,1765 ----
sub BornameSearch {
my ($env,$searchstring,$type)address@hidden;
! my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
***************
*** 1802,1806 ****
# $sth->execute;
$sth->finish;
- $dbh->disconnect;
return ($cnt,address@hidden);
}
--- 1788,1791 ----
***************
*** 1822,1826 ****
my ($cardnumber,$bornum)address@hidden;
$cardnumber = uc $cardnumber;
! my $dbh=C4Connect;
my $query;
if ($bornum eq ''){
--- 1807,1811 ----
my ($cardnumber,$bornum)address@hidden;
$cardnumber = uc $cardnumber;
! my $dbh = C4::Context->dbh;
my $query;
if ($bornum eq ''){
***************
*** 1834,1838 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
--- 1819,1822 ----
***************
*** 1854,1858 ****
sub borrissues {
my ($bornum)address@hidden;
! my $dbh=C4Connect;
my $query;
$query="Select * from issues,biblio,items where borrowernumber='$bornum' and
--- 1838,1842 ----
sub borrissues {
my ($bornum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items where borrowernumber='$bornum' and
***************
*** 1870,1874 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,address@hidden);
}
--- 1854,1857 ----
***************
*** 1897,1901 ****
sub allissues {
my ($bornum,$order,$limit)address@hidden;
! my $dbh=C4Connect;
my $query;
$query="Select * from issues,biblio,items,biblioitems
--- 1880,1884 ----
sub allissues {
my ($bornum,$order,$limit)address@hidden;
! my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items,biblioitems
***************
*** 1918,1922 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,address@hidden);
}
--- 1901,1904 ----
***************
*** 1940,1944 ****
sub borrdata2 {
my ($env,$bornum)address@hidden;
! my $dbh=C4Connect;
my $query="Select count(*) from issues where borrowernumber='$bornum' and
returndate is NULL";
--- 1922,1926 ----
sub borrdata2 {
my ($env,$bornum)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select count(*) from issues where borrowernumber='$bornum' and
returndate is NULL";
***************
*** 1958,1962 ****
my $data3=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data2->{'count(*)'},$data->{'count(*)'},$data3->{'sum(amountoutstanding)'});
--- 1940,1943 ----
***************
*** 1983,1987 ****
sub getboracctrecord {
my ($env,$params) = @_;
! my $dbh=C4Connect;
my @acctlines;
my $numlines=0;
--- 1964,1968 ----
sub getboracctrecord {
my ($env,$params) = @_;
! my $dbh = C4::Context->dbh;
my @acctlines;
my $numlines=0;
***************
*** 2007,2011 ****
}
$sth->finish;
- $dbh->disconnect;
return ($numlines,address@hidden,$total);
}
--- 1988,1991 ----
***************
*** 2051,2057 ****
=cut
#'
sub itemcount {
my ($env,$bibnum,$type)address@hidden;
! my $dbh=C4Connect;
my $query="Select * from items where
biblionumber=$bibnum ";
--- 2031,2041 ----
=cut
#'
+
+ # FIXME - There's also a &C4::Acquisitions::itemcount and
+ # &C4::Biblio::itemcount.
+ # Since they're all exported, acqui/acquire.pl doesn't compile with -w.
sub itemcount {
my ($env,$bibnum,$type)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select * from items where
biblionumber=$bibnum ";
***************
*** 2119,2123 ****
$sth2->finish;
$sth->finish;
- $dbh->disconnect;
return
($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount);
}
--- 2103,2106 ----
***************
*** 2161,2165 ****
sub itemcount2 {
my ($env,$bibnum,$type)address@hidden;
! my $dbh=C4Connect;
my $query="Select * from items,branches where
biblionumber=$bibnum and items.holdingbranch=branches.branchcode";
--- 2144,2148 ----
sub itemcount2 {
my ($env,$bibnum,$type)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="Select * from items,branches where
biblionumber=$bibnum and items.holdingbranch=branches.branchcode";
***************
*** 2202,2206 ****
$sth2->finish;
$sth->finish;
- $dbh->disconnect;
return (\%counts);
}
--- 2185,2188 ----
***************
*** 2237,2241 ****
sub ItemType {
my ($type)address@hidden;
! my $dbh=C4Connect;
my $query="select description from itemtypes where itemtype='$type'";
my $sth=$dbh->prepare($query);
--- 2219,2223 ----
sub ItemType {
my ($type)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="select description from itemtypes where itemtype='$type'";
my $sth=$dbh->prepare($query);
***************
*** 2243,2247 ****
my $dat=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return ($dat->{'description'});
}
--- 2225,2228 ----
***************
*** 2267,2271 ****
sub bibitems {
my ($bibnum) = @_;
! my $dbh = C4Connect;
my $query = "SELECT biblioitems.*,
itemtypes.*,
--- 2248,2252 ----
sub bibitems {
my ($bibnum) = @_;
! my $dbh = C4::Context->dbh;
my $query = "SELECT biblioitems.*,
itemtypes.*,
***************
*** 2286,2290 ****
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub bibitems
--- 2267,2270 ----
***************
*** 2306,2310 ****
#called from request.pl
my ($biblioitemnumber)address@hidden;
! my $dbh=C4Connect;
my $query="SELECT barcode, itemlost, holdingbranch FROM items
WHERE biblioitemnumber = ?
--- 2286,2290 ----
#called from request.pl
my ($biblioitemnumber)address@hidden;
! my $dbh = C4::Context->dbh;
my $query="SELECT barcode, itemlost, holdingbranch FROM items
WHERE biblioitemnumber = ?
***************
*** 2319,2323 ****
}
$sth->finish;
- $dbh->disconnect;
return(@barcodes);
}
--- 2299,2302 ----
***************
*** 2339,2343 ****
sub getwebsites {
my ($biblionumber) = @_;
! my $dbh = C4Connect;
my $query = "Select * from websites where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
--- 2318,2322 ----
sub getwebsites {
my ($biblionumber) = @_;
! my $dbh = C4::Context->dbh;
my $query = "Select * from websites where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
***************
*** 2359,2363 ****
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getwebsites
--- 2338,2341 ----
***************
*** 2378,2382 ****
sub getwebbiblioitems {
my ($biblionumber) = @_;
! my $dbh = C4Connect;
my $query = "Select * from biblioitems where biblionumber = $biblionumber
and itemtype = 'WEB'";
--- 2356,2360 ----
sub getwebbiblioitems {
my ($biblionumber) = @_;
! my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where biblionumber = $biblionumber
and itemtype = 'WEB'";
***************
*** 2393,2397 ****
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getwebbiblioitems
--- 2371,2374 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Search.pm,1.40,1.41,
Andrew Arensburger <=