From c3a1bd7117ee30e96a477c18c84a7a102962550f Mon Sep 17 00:00:00 2001 From: arensb Date: Sat, 5 Oct 2002 23:57:39 +0000 Subject: [PATCH] Replaced several prepare()/execute()/finish() sequences with do(). --- C4/Accounts2.pm | 85 ++++++++++++++------------ C4/Acquisitions.pm | 130 +++++++++++++++++++--------------------- C4/Circulation/Circ2.pm | 33 +++++----- 3 files changed, 129 insertions(+), 119 deletions(-) diff --git a/C4/Accounts2.pm b/C4/Accounts2.pm index bbec11d4a4..69486ae8b2 100755 --- a/C4/Accounts2.pm +++ b/C4/Accounts2.pm @@ -161,28 +161,32 @@ sub makepayment{ $sth->execute; my $data=$sth->fetchrow_hashref; $sth->finish; - # FIXME - This prepare/execute/finish sequence could be done with - # $dbh->do(), no? - my $updquery="Update accountlines set amountoutstanding=0 where - borrowernumber=$bornumber and accountno=$accountno"; - $sth=$dbh->prepare($updquery); - $sth->execute; - $sth->finish; + + $dbh->do(<prepare($updquery); - $usth->execute; - $usth->finish; + $dbh->do(<prepare($updquery); - $usth->execute; - $usth->finish; + $dbh->do(<{'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->do(<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'}')"; + $dbh->do(<{'itemnumber'}') +EOT } 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')"; + $desc=$dbh->quote($desc); + $dbh->do(<prepare($insert); - $sth->execute; - $sth->finish; } # fixcredit diff --git a/C4/Acquisitions.pm b/C4/Acquisitions.pm index 703d86aafe..ac075a3d1e 100644 --- a/C4/Acquisitions.pm +++ b/C4/Acquisitions.pm @@ -664,21 +664,19 @@ sub newbiblio { if ($biblio->{'seriestitle'}) { $series = 1 }; $sth->finish; - # FIXME - Use $dbh->do(); - $query = "insert into biblio set -biblionumber = $bibnum, -title = $biblio->{'title'}, -author = $biblio->{'author'}, -copyrightdate = $biblio->{'copyright'}, -serial = $series, -seriestitle = $biblio->{'seriestitle'}, -notes = $biblio->{'notes'}, -abstract = $biblio->{'abstract'}"; - $sth = $dbh->prepare($query); - $sth->execute; + $dbh->do(<{'title'}, + author = $biblio->{'author'}, + copyrightdate = $biblio->{'copyright'}, + serial = $series, + seriestitle = $biblio->{'seriestitle'}, + notes = $biblio->{'notes'}, + abstract = $biblio->{'abstract'} +EOT - $sth->finish; return($bibnum); } @@ -833,7 +831,6 @@ values ('$subject[$i]', $bibnum)"); sub modbibitem { my ($biblioitem) = @_; my $dbh = C4::Context->dbh; - my $query; # FIXME - # foreach my $field (qw( ... )) @@ -855,24 +852,24 @@ sub modbibitem { $biblioitem->{'size'} = $dbh->quote($biblioitem->{'size'}); $biblioitem->{'place'} = $dbh->quote($biblioitem->{'place'}); - $query = "Update biblioitems set -itemtype = $biblioitem->{'itemtype'}, -url = $biblioitem->{'url'}, -isbn = $biblioitem->{'isbn'}, -publishercode = $biblioitem->{'publishercode'}, -publicationyear = $biblioitem->{'publicationyear'}, -classification = $biblioitem->{'classification'}, -dewey = $biblioitem->{'dewey'}, -subclass = $biblioitem->{'subclass'}, -illus = $biblioitem->{'illus'}, -pages = $biblioitem->{'pages'}, -volumeddesc = $biblioitem->{'volumeddesc'}, -notes = $biblioitem->{'notes'}, -size = $biblioitem->{'size'}, -place = $biblioitem->{'place'} -where biblioitemnumber = $biblioitem->{'biblioitemnumber'}"; - - $dbh->do($query); + $dbh->do(<{'itemtype'}, + url = $biblioitem->{'url'}, + isbn = $biblioitem->{'isbn'}, + publishercode = $biblioitem->{'publishercode'}, + publicationyear = $biblioitem->{'publicationyear'}, + classification = $biblioitem->{'classification'}, + dewey = $biblioitem->{'dewey'}, + subclass = $biblioitem->{'subclass'}, + illus = $biblioitem->{'illus'}, + pages = $biblioitem->{'pages'}, + volumeddesc = $biblioitem->{'volumeddesc'}, + notes = $biblioitem->{'notes'}, + size = $biblioitem->{'size'}, + place = $biblioitem->{'place'} + WHERE biblioitemnumber = $biblioitem->{'biblioitemnumber'} +EOT } # sub modbibitem # FIXME - This is in effect identical to &C4::Biblio::modnote. @@ -881,12 +878,12 @@ where biblioitemnumber = $biblioitem->{'biblioitemnumber'}"; sub modnote { my ($bibitemnum,$note)=@_; 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->do(<do($query); - $query = "Delete from biblioitems -where biblioitemnumber = $biblioitemnumber"; - $dbh->do($query); + $dbh->do(<finish; @@ -1617,10 +1615,12 @@ where biblioitemnumber = $biblioitemnumber"; $dbh->do($query); } # while - $sth->finish; + $sth->finish; # FIXME - This is bogus, isn't it? - $query = "Delete from items where biblioitemnumber = $biblioitemnumber"; - $dbh->do($query); + $dbh->do(<dbh; - my $query; $website->{'biblionumber'} = $dbh->quote($website->{'biblionumber'}); $website->{'title'} = $dbh->quote($website->{'title'}); $website->{'description'} = $dbh->quote($website->{'description'}); $website->{'url'} = $dbh->quote($website->{'url'}); - $query = "Insert into websites set -biblionumber = $website->{'biblionumber'}, -title = $website->{'title'}, -description = $website->{'description'}, -url = $website->{'url'}"; - - $dbh->do($query); + $dbh->do(<{'biblionumber'}, + title = $website->{'title'}, + description = $website->{'description'}, + url = $website->{'url'} +EOT } # sub website =item updatewebsite @@ -1894,19 +1893,18 @@ the entry to update. sub updatewebsite { my ($website) = @_; my $dbh = C4::Context->dbh; - my $query; $website->{'title'} = $dbh->quote($website->{'title'}); $website->{'description'} = $dbh->quote($website->{'description'}); $website->{'url'} = $dbh->quote($website->{'url'}); - $query = "Update websites set -title = $website->{'title'}, -description = $website->{'description'}, -url = $website->{'url'} -where websitenumber = $website->{'websitenumber'}"; - - $dbh->do($query); + $dbh->do(<{'title'}, + description = $website->{'description'}, + url = $website->{'url'} + where websitenumber = $website->{'websitenumber'} +EOT } # sub updatewebsite =item deletewebsite @@ -1921,13 +1919,11 @@ Deletes the web site with number C<$websitenumber>. sub deletewebsite { my ($websitenumber) = @_; my $dbh = C4::Context->dbh; - # FIXME - $query is unnecessary: just use - # $dbh->do(<do($query); + + $dbh->do(<quote($fbr); $tbr = $dbh->quote($tbr); #new entry in branchtransfers.... - my $query = "insert into branchtransfers (itemnumber, frombranch, datearrived, tobranch) - values($itm, $fbr, now(), $tbr)"; - my $sth = $dbh->prepare($query); - $sth->execute; - $sth->finish; + $dbh->do(<do() - $query = "update items set datelastseen = now(), holdingbranch=$tbr where items.itemnumber=$itm"; - $sth = $dbh->prepare($query); - $sth->execute; - $sth->finish; + $dbh->do(<dbh; - # FIXME - Use $dbh->do(); - my $query="update items set itemlost=0 where itemnumber=$itemno"; - my $sth=$dbh->prepare($query); - $sth->execute; - $sth->finish; + + $dbh->do(<