Skip to content
Browse files

Merged with arensb-context branch: use C4::Context->dbh instead of

&C4Connect, and generally prefer C4::Context over C4::Database.
  • Loading branch information...
1 parent 7e1bad9 commit dbca39823f826d5e8d1cd7c0fc8d768be1f57b64 arensb committed Oct 5, 2002
Showing with 1,079 additions and 1,172 deletions.
  1. +3 −3 C4/Accounts.pm
  2. +12 −16 C4/Accounts2.pm
  3. +104 −121 C4/Acquisitions.pm
  4. +3 −2 C4/Auth.pm
  5. +111 −65 C4/Biblio.pm
  6. +10 −2 C4/BookShelves.pm
  7. +36 −72 C4/Catalogue.pm
  8. +2 −1 C4/Circmain.pm
  9. +0 −1 C4/Circulation.pm
  10. +4 −3 C4/Circulation/Borrissues.pm
  11. +10 −9 C4/Circulation/Borrower.pm
  12. +26 −29 C4/Circulation/Circ2.pm
  13. +7 −11 C4/Circulation/Fines.pm
  14. +13 −8 C4/Circulation/Issues.pm
  15. +12 −6 C4/Circulation/Main.pm
  16. +2 −1 C4/Circulation/Renewals.pm
  17. +7 −8 C4/Circulation/Renewals2.pm
  18. +4 −3 C4/Circulation/Returns.pm
  19. +10 −21 C4/Database.pm
  20. +3 −4 C4/Groups.pm
  21. +4 −0 C4/InterfaceCDK.pm
  22. +4 −7 C4/Koha.pm
  23. +10 −13 C4/Maintainance.pm
  24. +4 −12 C4/Output.pm
  25. +1 −0 C4/Print.pm
  26. +4 −7 C4/Reserves.pm
  27. +27 −28 C4/Reserves2.pm
  28. +40 −63 C4/Search.pm
  29. +2 −3 C4/Security.pm
  30. +7 −1 C4/SimpleMarc.pm
  31. +11 −21 C4/Stats.pm
  32. +2 −3 C4/Stock.pm
  33. +3 −2 C4/test.pl
  34. +188 −0 ChangeLog
  35. +0 −1 acqui.simple/addbooks.pl
  36. +4 −4 acqui.simple/addbookslccn.pl
  37. +9 −10 acqui.simple/bulkmarcimport.pl
  38. +16 −19 acqui.simple/marcimport.pl
  39. +4 −4 acqui.simple/processz3950queue
  40. +3 −3 acqui.simple/viewmarc.pl
  41. +5 −7 acqui/acquire.pl
  42. +5 −7 acqui/newbiblio.pl
  43. +7 −8 admin/aqbookfund.pl
  44. +8 −9 admin/aqbudget.pl
  45. +8 −13 admin/branches.pl
  46. +8 −8 admin/categorie.pl
  47. +8 −8 admin/categoryitem.pl
  48. +8 −8 admin/currency.pl
  49. +8 −8 admin/itemtypes.pl
  50. +7 −8 admin/marctagstructure.pl
  51. +7 −8 admin/printers.pl
  52. +7 −8 admin/stopwords.pl
  53. +7 −8 admin/systempreferences.pl
  54. +7 −11 bookcount.pl
  55. +2 −2 charges.pl
  56. +2 −2 circ/circulation.pl
  57. +7 −6 deletemem.pl
  58. +3 −24 detail.pl
  59. +2 −4 fixBranches.pl
  60. +32 −56 html-template/Search.pm
  61. +4 −25 html-template/detail.pl
  62. +4 −25 html-template/moredetail.pl
  63. +12 −29 html-template/search.pl
  64. +2 −3 insertdata.pl
  65. +2 −3 insertidata.pl
  66. +2 −3 insertjdata.pl
  67. +2 −2 logout.pl
  68. +0 −1 maint/catmaintain.pl
  69. +3 −3 maint/shiftbib.pl
  70. +8 −31 marc/MARCdetail.pl
  71. +3 −2 marc/fill_usmarc.pl
  72. +2 −6 marc/koha2marc
  73. +3 −7 marc/test
  74. +2 −4 marc/updatedb2marc.pl
  75. +13 −3 marc/viewmarc.pl
  76. +2 −3 memberentry.pl
  77. +3 −5 misc/fines2.pl
  78. +15 −17 misc/fixborrower.pl
  79. +2 −5 misc/fixcatalog.pl
  80. +2 −5 misc/fixorders.pl
  81. +2 −5 misc/fixrefs.pl
  82. +2 −4 misc/makebaskets.pl
  83. +2 −5 misc/makeformats.pl
  84. +0 −1 misc/tidyaccounts.pl
  85. +4 −25 moredetail.pl
  86. +2 −4 moremember.pl
  87. +4 −3 overdue.pl
  88. +3 −4 pay.pl
  89. +7 −26 search.pl
  90. +2 −3 sec/writeoff.pl
  91. +4 −5 stats2.pl
  92. +27 −29 telnet/borrwraper.pl
  93. +29 −30 telnet/doreturns.pl
  94. +2 −2 thesaurus_popup.pl
  95. +0 −1 tidyaccounts.pl
  96. +0 −1 updatebibitem.pl
  97. +0 −1 updatebiblio.pl
  98. +2 −3 updatecharges.pl
  99. +4 −5 updateitem.pl
  100. +3 −2 updater/thesaurus_create.pl
  101. +16 −3 updater/updatedatabase
  102. +4 −3 updater/updatedatabase2.pl
  103. +4 −25 userpage.pl
View
6 C4/Accounts.pm
@@ -21,7 +21,7 @@ package C4::Accounts; #assumes C4/Accounts
use strict;
require Exporter;
use DBI;
-use C4::Database;
+use C4::Context;
use C4::Format;
use C4::Search;
use C4::Stats;
@@ -103,7 +103,7 @@ sub checkaccount {
sub reconcileaccount {
#print put money owing give person opportunity to pay it off
my ($env,$dummy,$bornumber,$total)=@_;
- my $dbh = &C4Connect;
+ my $dbh = C4::Context->dbh;
#get borrower record
my $sth=$dbh->prepare("select * from borrowers
where borrowernumber=$bornumber");
@@ -144,7 +144,6 @@ sub reconcileaccount {
#Check if the borrower still owes
$total=&checkaccount($env,$bornumber,$dbh);
}
- $dbh->disconnect;
return($total);
}
@@ -186,6 +185,7 @@ sub recordpayment{
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
+ # FIXME - There's already a $usth in this scope.
my $usth = $dbh->prepare($updquery);
# print $updquery
$usth->execute;
View
28 C4/Accounts2.pm
@@ -21,7 +21,7 @@ package C4::Accounts2; #assumes C4/Accounts2
use strict;
require Exporter;
use DBI;
-use C4::Database;
+use C4::Context;
use C4::Stats;
use C4::Search;
use C4::Circulation::Circ2;
@@ -80,7 +80,7 @@ will be credited to the next one.
sub recordpayment{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
@@ -126,7 +126,6 @@ sub recordpayment{
$usth->finish;
UpdateStats($env,$branch,'payment',$data,'','','',$bornumber);
$sth->finish;
- $dbh->disconnect;
}
=item makepayment
@@ -152,7 +151,7 @@ sub makepayment{
# from their card, and put a note on the item record
my ($bornumber,$accountno,$amount,$user)=@_;
my $env;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
my $newamtos=0;
@@ -188,7 +187,6 @@ sub makepayment{
# branch code.
UpdateStats($env,$user,'payment',$amount,'','','',$bornumber);
$sth->finish;
- $dbh->disconnect;
#check to see what accounttype
if ($data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L'){
returnlost($bornumber,$data->{'itemnumber'});
@@ -233,7 +231,7 @@ sub getnextacctno {
# FIXME - I don't understand what this function does.
sub fixaccounts {
my ($borrowernumber,$accountno,$amount)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from accountlines where borrowernumber=$borrowernumber
and accountno=$accountno";
my $sth=$dbh->prepare($query);
@@ -243,19 +241,19 @@ sub fixaccounts {
my $diff=$amount-$data->{'amount'};
my $outstanding=$data->{'amountoutstanding'}+$diff;
$sth->finish;
+ # FIXME - Use $dbh->do();
$query="Update accountlines set amount='$amount',amountoutstanding='$outstanding' where
borrowernumber=$borrowernumber and accountno=$accountno";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
# FIXME - Never used, but not exported, either.
sub returnlost{
my ($borrnum,$itemnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $borrower=borrdata('',$borrnum); #from C4::Search;
my $upiss="Update issues set returndate=now() where
borrowernumber='$borrnum' and itemnumber='$itemnum' and returndate is null";
@@ -265,11 +263,11 @@ sub returnlost{
my @datearr = localtime(time);
my $date = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
my $bor="$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
+ # FIXME - Use $dbh->do();
my $upitem="Update items set paidfor='Paid for by $bor $date' where itemnumber='$itemnum'";
$sth=$dbh->prepare($upitem);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item manualinvoice
@@ -289,7 +287,7 @@ should be the empty string.
# FIXME - Okay, so what does this function do, really?
sub manualinvoice{
my ($bornum,$itemnum,$desc,$type,$amount,$user)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $insert;
$itemnum=~ s/ //g;
my %env;
@@ -317,19 +315,19 @@ sub manualinvoice{
$sth->finish;
$desc.=" ".$itemnum;
$desc=$dbh->quote($desc);
+ # FIXME - Use $dbh->do();
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
values ($bornum,$accountno,now(),'$amount',$desc,'$type','$amountleft','$data->{'itemnumber'}')";
} else {
$desc=$dbh->quote($desc);
+ # FIXME - Use $dbh->do();
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornum,$accountno,now(),'$amount',$desc,'$type','$amountleft')";
}
my $sth=$dbh->prepare($insert);
$sth->execute;
$sth->finish;
-
- $dbh->disconnect;
}
# fixcredit
@@ -340,7 +338,7 @@ sub manualinvoice{
sub fixcredit{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data,$barcode,$type,$user)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
@@ -415,7 +413,6 @@ sub fixcredit{
$usth->finish;
}
$sth->finish;
- $dbh->disconnect;
$env->{'branch'}=$user;
$type="Credit ".$type;
UpdateStats($env,$user,$type,$data,$user,'','',$bornumber);
@@ -428,7 +425,7 @@ sub fixcredit{
sub refund{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
@@ -469,7 +466,6 @@ sub refund{
$usth->finish;
}
$sth->finish;
- $dbh->disconnect;
return($amountleft);
}
View
225 C4/Acquisitions.pm
@@ -25,7 +25,7 @@ package C4::Acquisitions; #assumes C4/Acquisitions.pm
use strict;
require Exporter;
-use C4::Database;
+use C4::Context;
#use C4::Biblio;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -138,7 +138,7 @@ Results are ordered from most to least recent.
# FIXME - This exact function already exists in C4::Catalogue
sub getorders {
my ($supplierid)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
booksellerid='$supplierid' and (quantity > quantityreceived or
quantityreceived is NULL)
@@ -154,7 +154,6 @@ sub getorders {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return ($i,\@results);
}
@@ -163,14 +162,13 @@ sub getorders {
# the same as &C4::Search::itemcount
sub itemcount{
my ($biblio)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblionumber=$biblio";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data->{'count(*)'});
}
@@ -192,7 +190,7 @@ tables of the Koha database.
# FIXME - Almost the exact same function is already in C4::Catalogue
sub getorder{
my ($bi,$bib)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select ordernumber
from aqorders
where biblionumber=? and biblioitemnumber=?";
@@ -201,7 +199,6 @@ sub getorder{
my $ordnum=$sth->fetchrow_hashref;
$sth->finish;
my $order=getsingleorder($ordnum->{'ordernumber'});
- $dbh->disconnect;
# print $query;
return ($order,$ordnum->{'ordernumber'});
}
@@ -222,7 +219,7 @@ aqorderbreakdown tables of the Koha database.
# &C4::Catalogue::getsingleorder and &C4::Biblio::getsingleorder.
sub getsingleorder {
my ($ordnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
where aqorders.ordernumber=?
and biblio.biblionumber=aqorders.biblionumber and
@@ -232,7 +229,6 @@ sub getsingleorder {
$sth->execute($ordnum);
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
@@ -252,7 +248,7 @@ of the Koha database.
# FIXME - This exact function is already in C4::Catalogue
sub invoice {
my ($invoice)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where
booksellerinvoicenumber='$invoice'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@@ -266,7 +262,6 @@ sub invoice {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -290,7 +285,7 @@ C<@results> is sorted alphabetically by book title.
sub getallorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@@ -307,7 +302,6 @@ sub getallorders {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -316,7 +310,7 @@ sub getallorders {
sub getrecorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@@ -335,7 +329,6 @@ sub getrecorders {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -377,7 +370,7 @@ following keys:
# FIXME - The same function (modulo whitespace) appears in C4::Catalogue
sub ordersearch {
my ($search,$biblio,$catview)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select *,biblio.title from aqorders,biblioitems,biblio
where aqorders.biblioitemnumber = biblioitems.biblioitemnumber
and biblio.biblionumber=aqorders.biblionumber
@@ -420,7 +413,6 @@ sub ordersearch {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -440,7 +432,7 @@ aqbooksellers table in the Koha database.
# FIXME - This function appears in C4::Catalogue
sub bookseller {
my ($searchstring)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from aqbooksellers where name like '%$searchstring%' or
id = '$searchstring'";
my $sth=$dbh->prepare($query);
@@ -452,7 +444,6 @@ sub bookseller {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -471,7 +462,7 @@ are the fields of the aqorderbreakdown table in the Koha database.
# FIXME - This function appears in C4::Catalogue.
sub breakdown {
my ($id)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from aqorderbreakdown where ordernumber='$id'";
my $sth=$dbh->prepare($query);
$sth->execute;
@@ -482,7 +473,6 @@ sub breakdown {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
@@ -505,7 +495,7 @@ number of elements in C<@orders>.
# C4::Catalogue.pm
sub basket {
my ($basketno,$supplier)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select *,biblio.title from aqorders,biblio,biblioitems
where basketno='$basketno'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
@@ -526,7 +516,6 @@ sub basket {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -550,15 +539,14 @@ database, and returns it.
# remove out-of-date dummy orders.
# FIXME - This function appears in C4::Catalogue.pm
sub newbasket {
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select max(basketno) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_arrayref;
my $basket=$$data[0];
$basket++;
$sth->finish;
- $dbh->disconnect;
return($basket);
}
@@ -578,7 +566,7 @@ alphabetically by book fund name.
# FIXME - An identical function (without the hardcoded date) appears in
# C4::Catalogue
sub bookfunds {
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
=aqbudget.bookfundid
and aqbudget.startdate='2001-07-01'
@@ -592,7 +580,6 @@ sub bookfunds {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,@results);
}
@@ -610,7 +597,7 @@ table of the Koha database.
#'
# FIXME - This function (modulo whitespace) appears in C4::Catalogue
sub branches {
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from branches";
my $sth=$dbh->prepare($query);
my $i=0;
@@ -623,15 +610,14 @@ sub branches {
} # while
$sth->finish;
- $dbh->disconnect;
return($i, @results);
} # sub branches
# FIXME - POD. But I can't figure out what this function is doing
# FIXME - An almost identical function appears in C4::Catalogue
sub bookfundbreakdown {
my ($id)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
from aqorders,aqorderbreakdown where bookfundid='$id' and
aqorders.ordernumber=aqorderbreakdown.ordernumber and ((budgetdate >=
@@ -653,14 +639,15 @@ sub bookfundbreakdown {
}
}
$sth->finish;
- $dbh->disconnect;
return($spent,$comtd);
}
-
+
+# FIXME - This is in effect identical to &C4::Biblio::newbiblio.
+# Pick one and stick with it.
# XXX - POD
sub newbiblio {
my ($biblio) = @_;
- my $dbh = &C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select max(biblionumber) from biblio";
my $sth = $dbh->prepare($query);
$sth->execute;
@@ -677,6 +664,7 @@ sub newbiblio {
if ($biblio->{'seriestitle'}) { $series = 1 };
$sth->finish;
+ # FIXME - Use $dbh->do();
$query = "insert into biblio set
biblionumber = $bibnum,
title = $biblio->{'title'},
@@ -691,14 +679,15 @@ abstract = $biblio->{'abstract'}";
$sth->execute;
$sth->finish;
- $dbh->disconnect;
return($bibnum);
}
+# FIXME - This is in effect the same as &C4::Biblio::modbiblio.
+# Pick one and stick with it.
# XXX - POD
sub modbiblio {
my ($biblio) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query;
my $sth;
@@ -726,29 +715,30 @@ where biblionumber = $biblio->{'biblionumber'}";
$sth->execute;
$sth->finish;
- $dbh->disconnect;
return($biblio->{'biblionumber'});
} # sub modbiblio
+# FIXME - This is in effect identical to &C4::Biblio::modsubtitle.
+# Pick one and stick with it.
# XXX - POD
sub modsubtitle {
my ($bibnum, $subtitle) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "update bibliosubtitle set
subtitle = '$subtitle'
where biblionumber = $bibnum";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
} # sub modsubtitle
# XXX - POD
# FIXME - This is functionally identical to &C4::Biblio::modaddauthor
+# Pick one and stick with it.
sub modaddauthor {
my ($bibnum, $author) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Delete from additionalauthors where biblionumber = $bibnum";
my $sth = $dbh->prepare($query);
@@ -765,14 +755,14 @@ biblionumber = '$bibnum'";
$sth->finish;
} # if
-
- $dbh->disconnect;
} # sub modaddauthor
+# FIXME - This is in effect identical to &C4::Biblio::modsubject.
+# Pick one and stick with it.
# XXX - POD
sub modsubject {
my ($bibnum, $force, @subject) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $count = @subject;
my $error;
for (my $i = 0; $i < $count; $i++) {
@@ -834,14 +824,15 @@ values ('$subject[$i]', $bibnum)");
} # for
} # if
- $dbh->disconnect;
return($error);
} # sub modsubject
+# FIXME - This is very similar to &C4::Biblio::modbibitem.
+# Pick one and stick with it.
# XXX - POD
sub modbibitem {
my ($biblioitem) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query;
# FIXME -
@@ -882,27 +873,27 @@ place = $biblioitem->{'place'}
where biblioitemnumber = $biblioitem->{'biblioitemnumber'}";
$dbh->do($query);
-
- $dbh->disconnect;
} # sub modbibitem
+# FIXME - This is in effect identical to &C4::Biblio::modnote.
+# Pick one and stick with it.
# XXX - POD
sub modnote {
my ($bibitemnum,$note)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
+ # FIXME - Use $dbh->do();
my $query="update biblioitems set notes='$note' where
biblioitemnumber='$bibitemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
# XXX - POD
# FIXME - &C4::Biblio::newbiblioitem is quite similar to this
sub newbiblioitem {
my ($biblioitem) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select max(biblioitemnumber) from biblioitems";
my $sth = $dbh->prepare($query);
my $data;
@@ -963,28 +954,29 @@ place = $biblioitem->{'place'}";
$sth->execute;
$sth->finish;
- $dbh->disconnect;
return($bibitemnum);
}
+# FIXME - This is in effect identical to &C4::Biblio::newsubject.
+# Pick one and stick with it.
# XXX - POD
sub newsubject {
my ($bibnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="insert into bibliosubject (biblionumber) values
($bibnum)";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
# XXX - POD
# FIXME - This is in effect the same as &C4::Biblio::newsubtitle
+# Pick one and stick with it.
sub newsubtitle {
my ($bibnum, $subtitle) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
$subtitle = $dbh->quote($subtitle);
my $query = "insert into bibliosubtitle set
biblionumber = $bibnum,
@@ -994,7 +986,6 @@ subtitle = $subtitle";
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item neworder
@@ -1033,7 +1024,7 @@ sub neworder {
} else {
$sub=0;
}
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="insert into aqorders (biblionumber,title,basketno,
quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
biblioitemnumber,rrp,ecost,gst,unitprice,subscription,booksellerinvoicenumber)
@@ -1059,7 +1050,6 @@ sub neworder {
# print $query;
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item delorder
@@ -1079,7 +1069,7 @@ marc_biblio tables of the Koha database.
# FIXME - This function appears in C4::Catalogue
sub delorder {
my ($bibnum,$ordnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update aqorders set datecancellationprinted=now()
where biblionumber='$bibnum' and
ordernumber='$ordnum'";
@@ -1091,7 +1081,6 @@ sub delorder {
if ($count == 0){
delbiblio($bibnum);
}
- $dbh->disconnect;
}
=item modorder
@@ -1114,7 +1103,7 @@ table are also updated to the new book fund ID.
# FIXME - This function appears in C4::Catalogue
sub modorder {
my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update aqorders set title='$title',
quantity='$quantity',listprice='$listprice',basketno='$basketno',
rrp='$rrp',ecost='$ecost',unitprice='$cost',
@@ -1131,7 +1120,6 @@ sub modorder {
# print $query;
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item newordernum
@@ -1146,15 +1134,14 @@ database, and returns it.
# FIXME - Race condition
# FIXME - This function appears in C4::Catalogue
sub newordernum {
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select max(ordernumber) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_arrayref;
my $ordnum=$$data[0];
$ordnum++;
$sth->finish;
- $dbh->disconnect;
return($ordnum);
}
@@ -1178,7 +1165,7 @@ Also updates the book fund ID in the aqorderbreakdown table.
# FIXME - This function appears in C4::Catalogue
sub receiveorder {
my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update aqorders set quantityreceived='$quantrec',
datereceived=now(),booksellerinvoicenumber='$invoiceno',
biblioitemnumber=$bibitemno,unitprice='$cost',freight='$freight',
@@ -1195,7 +1182,6 @@ sub receiveorder {
# print $query;
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item updaterecorder
@@ -1215,7 +1201,7 @@ C<$user> is ignored.
# FIXME - This function appears in C4::Catalogue
sub updaterecorder{
my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update aqorders set
unitprice='$cost', rrp='$rrp'
where biblionumber=$biblio and ordernumber=$ordnum
@@ -1230,7 +1216,6 @@ sub updaterecorder{
# print $query;
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item curconvert
@@ -1249,13 +1234,12 @@ to one.
# C4::Catalogue
sub curconvert {
my ($currency,$price)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select rate from currency where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
my $cur=$data->{'rate'};
if ($cur==0){
$cur=1;
@@ -1278,7 +1262,7 @@ keys are the fields from the currency table in the Koha database.
#'
# FIXME - This function appears in C4::Catalogue
sub getcurrencies {
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from currency";
my $sth=$dbh->prepare($query);
$sth->execute;
@@ -1289,21 +1273,19 @@ sub getcurrencies {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
# FIXME - This function appears in C4::Catalogue. Neither one is used.
sub getcurrency {
my ($cur)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from currency where currency='$cur'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
@@ -1318,12 +1300,11 @@ Sets the exchange rate for C<$currency> to be C<$newrate>.
# FIXME - This function appears in C4::Catalogue
sub updatecurrencies {
my ($currency,$rate)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update currency set rate=$rate where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
=item updatesup
@@ -1344,7 +1325,7 @@ C<&updatesup> with the result.
# FIXME - This function appears in C4::Catalogue
sub updatesup {
my ($data)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Update aqbooksellers set
name='$data->{'name'}',address1='$data->{'address1'}',address2='$data->{'address2'}',
address3='$data->{'address3'}',address4='$data->{'address4'}',postal='$data->{'postal'}',
@@ -1362,14 +1343,13 @@ sub updatesup {
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
# print $query;
}
# XXX - POD
sub insertsup {
my ($data)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
$sth->execute;
my $data2=$sth->fetchrow_hashref;
@@ -1379,7 +1359,6 @@ sub insertsup {
$sth->execute;
$sth->finish;
$data->{'id'}=$data2->{'max(id)'};
- $dbh->disconnect;
updatesup($data);
return($data->{'id'});
}
@@ -1397,9 +1376,11 @@ Returns the ID of the newly-created bookseller.
=cut
#'
# FIXME - This function appears in C4::Catalogue
+# FIXME - This is different from &C4::Biblio::newitems, though both
+# are exported.
sub newitems {
my ($item, @barcodes) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select max(itemnumber) from items";
my $sth = $dbh->prepare($query);
my $data;
@@ -1448,14 +1429,15 @@ notforloan = $item->{'loan'}";
$itemnumber++;
} # for
- $dbh->disconnect;
return($error);
}
+# FIXME - This is the same as &C4::Biblio::Checkitems.
+# Pick one and stick with it.
# XXX - POD
sub checkitems{
my ($count,@barcodes)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $error;
for (my $i=0;$i<$count;$i++){
$barcodes[$i]=uc $barcodes[$i];
@@ -1467,14 +1449,16 @@ sub checkitems{
}
$sth->finish;
}
- $dbh->disconnect;
return($error);
}
+# FIXME - This appears to be functionally equivalent to
+# &C4::Biblio::moditem.
+# Pick one and stick with it.
# XXX - POD
sub moditem {
my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn,$replacement)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update items set biblioitemnumber=$bibitemnum,
barcode='$barcode',itemnotes='$notes'
where itemnumber=$itemnum";
@@ -1493,38 +1477,37 @@ sub moditem {
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
# FIXME - This function appears in C4::Catalogue. Neither one is used
sub updatecost{
my($price,$rrp,$itemnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="update items set price='$price',replacementprice='$rrp'
where itemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
+# FIXME - This is identical to &C4::Biblio::countitems.
+# Pick one and stick with it.
# XXX - POD
sub countitems{
my ($bibitemnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblioitemnumber='$bibitemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data->{'count(*)'});
}
# FIXME - This function appears in C4::Catalogue. Neither one is used.
sub findall {
my ($biblionumber)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems,items,itemtypes where
biblioitems.biblionumber=$biblionumber
and biblioitems.biblioitemnumber=items.biblioitemnumber and
@@ -1539,14 +1522,13 @@ sub findall {
$i++;
}
$sth->finish;
- $dbh->disconnect;
return(@results);
}
# FIXME - This function appears in C4::Catalogue. Neither one is used
sub needsmod{
my ($bibitemnum,$itemtype)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
and itemtype='$itemtype'";
my $sth=$dbh->prepare($query);
@@ -1556,15 +1538,15 @@ sub needsmod{
$result=1;
}
$sth->finish;
- $dbh->disconnect;
return($result);
}
# FIXME - A nearly-identical function, appears in C4::Biblio
+# Pick one and stick with it.
# XXX - POD
sub delitem{
my ($itemnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="select * from items where itemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@@ -1583,13 +1565,14 @@ sub delitem{
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
+# FIXME - This is functionally identical to &C4::Biblio::deletebiblioitem.
+# Pick one and stick with it.
# XXX - POD
sub deletebiblioitem {
my ($biblioitemnumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems
where biblioitemnumber = $biblioitemnumber";
my $sth = $dbh->prepare($query);
@@ -1639,13 +1622,14 @@ where biblioitemnumber = $biblioitemnumber";
$query = "Delete from items where biblioitemnumber = $biblioitemnumber";
$dbh->do($query);
- $dbh->disconnect;
} # sub deletebiblioitem
+# FIXME - This is functionally identical to &C4::Biblio::delbiblio.
+# Pick one and stick with it.
# XXX - POD
sub delbiblio{
my ($biblio)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="select * from biblio where biblionumber=$biblio";
my $sth=$dbh->prepare($query);
$sth->execute;
@@ -1668,12 +1652,11 @@ sub delbiblio{
}
$sth->finish;
- $dbh->disconnect;
}
# XXX - POD
sub getitemtypes {
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "select * from itemtypes";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query" . $dbh->errstr;
@@ -1688,14 +1671,15 @@ sub getitemtypes {
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getitemtypes
+# FIXME - This is identical to &C4::Biblio::getitemtypes.
+# Pick one and stick with it.
# XXX - POD
sub getbiblio {
my ($biblionumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblio where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query\n" . $dbh->errstr;
@@ -1710,14 +1694,13 @@ sub getbiblio {
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getbiblio
# XXX - POD
sub getbiblioitem {
my ($biblioitemnum) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where
biblioitemnumber = $biblioitemnum";
my $sth = $dbh->prepare($query);
@@ -1732,14 +1715,15 @@ biblioitemnumber = $biblioitemnum";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getbiblioitem
+# FIXME - This is identical to &C4::Biblio::getbiblioitem.
+# Pick one and stick with it.
# XXX - POD
sub getbiblioitembybiblionumber {
my ($biblionumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where biblionumber =
$biblionumber";
my $sth = $dbh->prepare($query);
@@ -1754,14 +1738,16 @@ $biblionumber";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub
+# FIXME - This is identical to
+# &C4::Biblio::getbiblioitembybiblionumber.
+# Pick one and stick with it.
# XXX - POD
sub getitemsbybiblioitem {
my ($biblioitemnum) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from items, biblio where
biblio.biblionumber = items.biblionumber and biblioitemnumber
= $biblioitemnum";
@@ -1778,14 +1764,15 @@ biblio.biblionumber = items.biblionumber and biblioitemnumber
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getitemsbybiblioitem
+# FIXME - This is identical to &C4::Biblio::isbnsearch.
+# Pick one and stick with it.
# XXX - POD
sub isbnsearch {
my ($isbn) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $count = 0;
my $query;
my $sth;
@@ -1804,7 +1791,6 @@ and isbn = $isbn";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub isbnsearch
@@ -1827,7 +1813,7 @@ and biblioitems tables in the Koha database.
# FIXME - This function appears in C4::Catalogue
sub websitesearch {
my ($keywordlist) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select distinct biblio.* from biblio, biblioitems where
biblio.biblionumber = biblioitems.biblionumber and (";
my $count = 0;
@@ -1860,7 +1846,6 @@ biblio.biblionumber = biblioitems.biblionumber and (";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub websitesearch
@@ -1877,7 +1862,7 @@ are mandatory.
# FIXME - This function appears in C4::Catalogue
sub addwebsite {
my ($website) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query;
$website->{'biblionumber'} = $dbh->quote($website->{'biblionumber'});
@@ -1892,8 +1877,6 @@ description = $website->{'description'},
url = $website->{'url'}";
$dbh->do($query);
-
- $dbh->disconnect;
} # sub website
=item updatewebsite
@@ -1910,7 +1893,7 @@ the entry to update.
# FIXME - This function appears in C4::Catalogue
sub updatewebsite {
my ($website) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query;
$website->{'title'} = $dbh->quote($website->{'title'});
@@ -1924,8 +1907,6 @@ url = $website->{'url'}
where websitenumber = $website->{'websitenumber'}";
$dbh->do($query);
-
- $dbh->disconnect;
} # sub updatewebsite
=item deletewebsite
@@ -1939,12 +1920,14 @@ Deletes the web site with number C<$websitenumber>.
# FIXME - This function appears in C4::Catalogue
sub deletewebsite {
my ($websitenumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
+ # FIXME - $query is unnecessary: just use
+ # $dbh->do(<<EOT);
+ # DELETE FROM websites where websitenumber=$websitenumber
+ # EOT
my $query = "Delete from websites where websitenumber = $websitenumber";
$dbh->do($query);
-
- $dbh->disconnect;
} # sub deletewebsite
View
5 C4/Auth.pm
@@ -23,7 +23,7 @@ use Digest::MD5 qw(md5_base64);
require Exporter;
-use C4::Database;
+use C4::Context;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -51,7 +51,7 @@ sub checkauth {
my $sessionID=$query->cookie('sessionID');
my $message='';
- my $dbh=C4Connect();
+ my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select userid,ip,lasttime from sessions where sessionid=?");
$sth->execute($sessionID);
if ($sth->rows) {
@@ -189,6 +189,7 @@ sub checkpw {
return 1;
}
}
+ # FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare("select password from borrowers where cardnumber=?");
$sth->execute($userid);
if ($sth->rows) {
View
176 C4/Biblio.pm
@@ -1,13 +1,40 @@
package C4::Biblio;
# $Id$
# $Log$
+# Revision 1.15 2002/10/05 09:49:25 arensb
+# Merged with arensb-context branch: use C4::Context->dbh instead of
+# &C4Connect, and generally prefer C4::Context over C4::Database.
+#
# Revision 1.14 2002/10/03 11:28:18 tipaul
# Extending Context.pm to add stopword management and using it in MARC-API.
# First benchmarks show a medium speed improvement, which is nice as this part is heavily called.
#
# Revision 1.13 2002/10/02 16:26:44 tipaul
# road to 1.3.1
#
+# Revision 1.12.2.4 2002/10/05 07:09:31 arensb
+# Merged in changes from main branch.
+#
+# Revision 1.12.2.3 2002/10/05 06:12:10 arensb
+# Added a whole mess of FIXME comments.
+#
+# Revision 1.12.2.2 2002/10/05 04:03:14 arensb
+# Added some missing semicolons.
+#
+# Revision 1.12.2.1 2002/10/04 02:24:01 arensb
+# Use C4::Connect instead of C4::Database, C4::Connect->dbh instead
+# C4Connect.
+#
+# Revision 1.12.2.3 2002/10/05 06:12:10 arensb
+# Added a whole mess of FIXME comments.
+#
+# Revision 1.12.2.2 2002/10/05 04:03:14 arensb
+# Added some missing semicolons.
+#
+# Revision 1.12.2.1 2002/10/04 02:24:01 arensb
+# Use C4::Connect instead of C4::Database, C4::Connect->dbh instead
+# C4Connect.
+#
# Revision 1.12 2002/10/01 11:48:51 arensb
# Added some FIXME comments, mostly marking duplicate functions.
#
@@ -106,6 +133,7 @@ package C4::Biblio;
use strict;
require Exporter;
+use C4::Context;
use C4::Database;
use MARC::Record;
@@ -153,7 +181,7 @@ $VERSION = 0.01;
# your exported package globals go here,
# as well as any optionally exported functions
-@EXPORT_OK = qw($Var1 %Hashit);
+@EXPORT_OK = qw($Var1 %Hashit); # FIXME - These are never used
#
#
@@ -240,7 +268,7 @@ $VERSION = 0.01;
=head1 AUTHOR
Paul POULAIN paul.poulain@free.fr
-/
+
=cut
sub MARCgettagslib {
@@ -451,6 +479,7 @@ sub MARCgetitem {
from marc_subfield_table
where bibid=? and tagorder=? order by subfieldorder
");
+ # FIXME - There's already a $sth2 in this scope.
my $sth2=$dbh->prepare("select subfieldvalue from marc_blob_subfield where blobidlink=?");
$sth->execute($bibid,$tagorder);
while (my $row=$sth->fetchrow_hashref) {
@@ -758,14 +787,18 @@ sub MARCmarc2koha {
while (($field)=$sth2->fetchrow) {
$result=&MARCmarc2kohaOneField($sth,"biblio",$field,$record,$result);
}
+ # FIXME - There's already a $sth2 in this scope.
my $sth2=$dbh->prepare("SHOW COLUMNS from biblioitems");
$sth2->execute;
+ # FIXME - There's already a $field in this scope.
my $field;
while (($field)=$sth2->fetchrow) {
$result=&MARCmarc2kohaOneField($sth,"biblioitems",$field,$record,$result);
}
+ # FIXME - There's already a $sth2 in this scope.
my $sth2=$dbh->prepare("SHOW COLUMNS from items");
$sth2->execute;
+ # FIXME - There's already a $field in this scope.
my $field;
while (($field)=$sth2->fetchrow) {
$result = &MARCmarc2kohaOneField($sth,"items",$field,$record,$result);
@@ -1086,7 +1119,6 @@ where biblionumber = $biblio->{'biblionumber'}";
$sth->execute;
$sth->finish;
- $dbh->disconnect;
return($biblio->{'biblionumber'});
} # sub modbiblio
@@ -1123,8 +1155,6 @@ sub OLDmodaddauthor {
$sth->finish;
} # if
-
- $dbh->disconnect;
} # sub modaddauthor
@@ -1522,22 +1552,22 @@ sub OLDdelbiblio{
# FIXME - This is the same as &C4::Acquisitions::itemcount, but not
# the same as &C4::Search::itemcount
+# Since they're both exported, acqui/acquire.pl doesn't compile with -w.
sub itemcount{
my ($biblio)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblionumber=$biblio";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data->{'count(*)'});
}
sub getorder{
my ($bi,$bib)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select ordernumber
from aqorders
where biblionumber=? and biblioitemnumber=?";
@@ -1546,7 +1576,6 @@ sub getorder{
my $ordnum=$sth->fetchrow_hashref;
$sth->finish;
my $order=getsingleorder($ordnum->{'ordernumber'});
- $dbh->disconnect;
# print $query;
return ($order,$ordnum->{'ordernumber'});
}
@@ -1555,7 +1584,7 @@ sub getorder{
# &C4::Acquisitions::getsingleorder and &C4::Catalogue::getsingleorder
sub getsingleorder {
my ($ordnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
where aqorders.ordernumber=?
and biblio.biblionumber=aqorders.biblionumber and
@@ -1565,73 +1594,80 @@ sub getsingleorder {
$sth->execute($ordnum);
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data);
}
+# FIXME - This is in effect identical to &C4::Acquisitions::newbiblio.
+# Pick one and stick with it.
sub newbiblio {
my ($biblio) = @_;
- my $dbh = &C4Connect;
+ my $dbh = C4::Context->dbh;
my $bibnum=OLDnewbiblio($dbh,$biblio);
# TODO : MARC add
- $dbh->disconnect;
return($bibnum);
}
+# FIXME - This is in effect the same as &C4::Acquisitions::modbiblio.
+# Pick one and stick with it.
sub modbiblio {
my ($biblio) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $biblionumber=OLDmodbiblio($dbh,$biblio);
- $dbh->disconnect;
return($biblionumber);
} # sub modbiblio
+# FIXME - This is in effect identical to &C4::Acquisitions::modsubtitle.
+# Pick one and stick with it.
sub modsubtitle {
my ($bibnum, $subtitle) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDmodsubtitle($dbh,$bibnum,$subtitle);
- $dbh->disconnect;
} # sub modsubtitle
# FIXME - This is functionally identical to
# &C4::Acquisitions::modaddauthor
+# Pick one and stick with it.
sub modaddauthor {
my ($bibnum, $author) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDmodaddauthor($dbh,$bibnum,$author);
- $dbh->disconnect;
} # sub modaddauthor
+# FIXME - This is in effect identical to &C4::Acquisitions::modsubject.
+# Pick one and stick with it.
sub modsubject {
my ($bibnum, $force, @subject) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $error= &OLDmodsubject($dbh,$bibnum,$force, @subject);
return($error);
} # sub modsubject
+# FIXME - This is very similar to &C4::Acquisitions::modbibitem.
+# Pick one and stick with it.
sub modbibitem {
my ($biblioitem) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDmodbibitem($dbh,$biblioitem);
my $MARCbibitem = MARCkoha2marcBiblio($dbh,$biblioitem);
&MARCmodbiblio($dbh,$biblioitem->{biblionumber},0,$MARCbibitem);
- $dbh->disconnect;
} # sub modbibitem
+# FIXME - This is in effect identical to &C4::Acquisitions::modnote.
+# Pick one and stick with it.
sub modnote {
my ($bibitemnum,$note)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDmodnote($dbh,$bibitemnum,$note);
- $dbh->disconnect;
}
# FIXME - This is quite similar in effect to &C4::newbiblioitem,
-# except for the MARC stuff.
+# except for the MARC stuff. There's also a &newbiblioitem in
+# acqui.simple/addbookslccn.pl
sub newbiblioitem {
my ($biblioitem) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $bibitemnum = &OLDnewbiblioitem($dbh,$biblioitem);
# print STDERR "bibitemnum : $bibitemnum\n";
my $MARCbiblio= MARCkoha2marcBiblio($dbh,$biblioitem->{biblionumber},$bibitemnum);
@@ -1640,25 +1676,27 @@ sub newbiblioitem {
return($bibitemnum);
}
+# FIXME - This is in effect identical to &C4::Acquisitions::newsubject.
+# Pick one and stick with it.
sub newsubject {
my ($bibnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDnewsubject($dbh,$bibnum);
- $dbh->disconnect;
}
# FIXME - This is just a wrapper around &OLDnewsubtitle
# FIXME - This is in effect the same as &C4::Acquisitions::newsubtitle
sub newsubtitle {
my ($bibnum, $subtitle) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDnewsubtitle($dbh,$bibnum,$subtitle);
- $dbh->disconnect;
}
+# FIXME - This is different from &C4::Acquisitions::newitems, though
+# both are exported.
sub newitems {
my ($item, @barcodes) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $errors;
my $itemnumber;
my $error;
@@ -1671,14 +1709,16 @@ sub newitems {
&MARCadditem($dbh,$MARCitem,$item->{biblionumber});
# print STDERR "MARCmodbiblio called\n";
}
- $dbh->disconnect;
return($errors);
}
+# FIXME - This appears to be functionally equivalent to
+# &C4::Acquisitions::moditem.
+# Pick one and stick with it.
sub moditem {
my ($item) = @_;
# my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn,$replacement)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDmoditem($dbh,$item);
warn "biblionumber : $item->{'biblionumber'} / $item->{'itemnum'}\n";
my $MARCitem = &MARCkoha2marcItem($dbh,$item->{'biblionumber'},$item->{'itemnum'});
@@ -1687,12 +1727,13 @@ sub moditem {
# print STDERR "MARCitem ".$MARCitem->as_formatted()."\n";
my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$item->{biblionumber});
&MARCmoditem($dbh,$MARCitem,$bibid,$item->{itemnum},0);
- $dbh->disconnect;
}
+# FIXME - This is the same as &C4::Acquisitions::Checkitems.
+# Pick one and stick with it.
sub checkitems{
my ($count,@barcodes)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $error;
for (my $i=0;$i<$count;$i++){
$barcodes[$i]=uc $barcodes[$i];
@@ -1704,48 +1745,53 @@ sub checkitems{
}
$sth->finish;
}
- $dbh->disconnect;
return($error);
}
+# FIXME - This is identical to &C4::Acquisitions::countitems.
+# Pick one and stick with it.
sub countitems{
my ($bibitemnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblioitemnumber='$bibitemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data->{'count(*)'});
}
# FIXME - This is just a wrapper around &OLDdelitem, and acts
# identically to &C4::Acquisitions::delitem
+# Pick one and stick with it.
sub delitem{
my ($itemnum)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDdelitem($dbh,$itemnum);
- $dbh->disconnect;
}
+# FIXME - This is functionally identical to
+# &C4::Acquisitions::deletebiblioitem.
+# Pick one and stick with it.
sub deletebiblioitem {
my ($biblioitemnumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDdeletebiblioitem($dbh,$biblioitemnumber);
- $dbh->disconnect;
} # sub deletebiblioitem
+# FIXME - This is functionally identical to &C4::Acquisitions::delbiblio.
+# Pick one and stick with it.
sub delbiblio {
my ($biblio)=@_;
- my $dbh=C4Connect;
+ my $dbh = C4::Context->dbh;
&OLDdelbiblio($dbh,$biblio);
- $dbh->disconnect;
}
+# FIXME - This is identical to &C4::Acquisitions::getitemtypes.
+# Pick one and stick with it.
sub getitemtypes {
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "select * from itemtypes";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query" . $dbh->errstr;
@@ -1760,13 +1806,12 @@ sub getitemtypes {
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getitemtypes
sub getbiblio {
my ($biblionumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblio where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query\n" . $dbh->errstr;
@@ -1781,13 +1826,14 @@ sub getbiblio {
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getbiblio
+# FIXME - This is identical to &C4::Acquisitions::getbiblioitem.
+# Pick one and stick with it.
sub getbiblioitem {
my ($biblioitemnum) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where
biblioitemnumber = $biblioitemnum";
my $sth = $dbh->prepare($query);
@@ -1802,13 +1848,15 @@ biblioitemnumber = $biblioitemnum";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getbiblioitem
+# FIXME - This is identical to
+# &C4::Acquisitions::getbiblioitembybiblionumber.
+# Pick one and stick with it.
sub getbiblioitembybiblionumber {
my ($biblionumber) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where biblionumber =
$biblionumber";
my $sth = $dbh->prepare($query);
@@ -1823,13 +1871,15 @@ $biblionumber";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub
+# FIXME - This is identical to
+# &C4::Acquisitions::getbiblioitembybiblionumber.
+# Pick one and stick with it.
sub getitemsbybiblioitem {
my ($biblioitemnum) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $query = "Select * from items, biblio where
biblio.biblionumber = items.biblionumber and biblioitemnumber
= $biblioitemnum";
@@ -1846,13 +1896,14 @@ biblio.biblionumber = items.biblionumber and biblioitemnumber
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub getitemsbybiblioitem
+# FIXME - This is identical to &C4::Acquisitions::isbnsearch.
+# Pick one and stick with it.
sub isbnsearch {
my ($isbn) = @_;
- my $dbh = C4Connect;
+ my $dbh = C4::Context->dbh;
my $count = 0;
my $query;
my $sth;
@@ -1871,7 +1922,6 @@ and isbn = $isbn";
} # while
$sth->finish;
- $dbh->disconnect;
return($count, @results);
} # sub isbnsearch
@@ -2000,7 +2050,7 @@ sub getoraddbiblio {
sub OLD_MAYBE_DELETED_newBiblioItem {
my ($env, $biblioitem) = @_;
- my $dbh=&C4Connect;
+ my $dbh = C4::Context->dbh;
my $biblionumber=$biblioitem->{'biblionumber'};
my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
my $volume=$biblioitem->{'volume'};
@@ -2254,13 +2304,12 @@ sub OLD_MAYBE_DELETED_newBiblioItem {
addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
}
$sth->finish;
- $dbh->disconnect;
return ($env, $Record_ID);
}
sub OLD_MAYBE_DELETED_newItem {
my ($env, $Record_ID, $item) = @_;
- my $dbh=&C4Connect;
+ my $dbh = C4::Context->dbh;
my $barcode=$item->{'barcode'};
my $q_barcode=$dbh->quote($barcode);
my $biblionumber=$item->{'biblionumber'};
@@ -2363,7 +2412,7 @@ sub OLD_MAYBE_DELETED_updateBiblio {
my ($env, $biblio) = @_;
my $Record_ID;
my $biblionumber=$biblio->{'biblionumber'};
- my $dbh=&C4Connect;
+ my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select * from biblio where biblionumber=$biblionumber");
$sth->execute;
my $origbiblio=$sth->fetchrow_hashref;
@@ -2511,7 +2560,7 @@ sub OLD_MAYBE_DELETED_updateBiblioItem {
# modified, and log all changes.
my ($env, $biblioitem) = @_;
- my $dbh=&C4Connect;
+ my $dbh = C4::Context->dbh;
my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
my $sth=$dbh->prepare("select * from biblioitems where biblioitemnumber=$biblioitemnumber");
@@ -2631,8 +2680,6 @@ sub OLD_MAYBE_DELETED_updateBiblioItem {