From 58e5e0a236824fe21b1927ffefe079af040517b9 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Mon, 28 Apr 2008 15:31:27 -0500 Subject: [PATCH] BUGFIX - get_batches argument counterproductive. NONE of the Labels code Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index 285fbbb4f8..f6bd08a8b7 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -353,24 +353,14 @@ sub get_highest_batch { sub get_batches { - my ( $batch_type ) = @_; - my $dbh = C4::Context->dbh; - my $q = "SELECT batch_id, COUNT(*) AS num FROM $batch_type GROUP BY batch_id"; - my $sth = $dbh->prepare($q); + # my $q = "SELECT batch_id, COUNT(*) AS num FROM " . shift . " GROUP BY batch_id"; + # FIXEDME: There is only ONE table with batch_id, so why try to select a different one? + # get_batches() was frequently being called w/ no args, crashing DBD + my $q = "SELECT batch_id, COUNT(*) AS num FROM labels GROUP BY batch_id"; + my $sth = C4::Context->dbh->prepare($q); $sth->execute(); - my @resultsloop; - while ( my $data = $sth->fetchrow_hashref ) { - push( @resultsloop, $data ); - } - $sth->finish; - -# Not sure why we are doing this rather than simply telling the user that no batches are currently defined. -# So I'm commenting this out and modifying label-manager.tmpl to properly inform the user as stated. -fbcit - # adding a dummy batch=1 value , if none exists in the db -# if ( !scalar(@resultsloop) ) { -# push( @resultsloop, { batch_id => '1' , num => '0' } ); -# } - return @resultsloop; + my $batches = $sth->fetchall_arrayref({}); + return @$batches; } sub delete_batch { -- 2.20.1