[Koha-patches] [PATCH 41/78] changes in ImportBatch

paul.poulain at biblibre.com paul.poulain at biblibre.com
Thu May 28 18:32:51 CEST 2009


From: Paul Poulain <paul.poulain at biblibre.com>

not sure it's new_acq related. Should ask john
---
 C4/ImportBatch.pm |   50 +++++++++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm
index 9ceb15a..0de569c 100644
--- a/C4/ImportBatch.pm
+++ b/C4/ImportBatch.pm
@@ -134,7 +134,7 @@ sub GetImportRecordMarc {
     $sth->execute($import_record_id);
     my ($marc, $encoding) = $sth->fetchrow();
     $sth->finish();
-    return $marc;
+    return $marc, $encoding;
 
 }
 
@@ -745,18 +745,21 @@ sub GetImportBatchRangeDesc {
     my ($offset, $results_per_group) = @_;
 
     my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare_cached("SELECT * FROM import_batches
+    my $query = "SELECT * FROM import_batches
                                     WHERE batch_type = 'batch'
-                                    ORDER BY import_batch_id DESC
-                                    LIMIT ? OFFSET ?");
-    $sth->bind_param(1, $results_per_group);
-    $sth->bind_param(2, $offset);
-
-    my $results = [];
-    $sth->execute();
-    while (my $row = $sth->fetchrow_hashref) {
-        push @$results, $row;
+                                    ORDER BY import_batch_id DESC";
+    my @params;
+    if ($offset){
+        if ($results_per_group){
+            $query .= " LIMIT ?";
+            push(@params, $results_per_group);
+        }
+        $query .= " OFFSET ?";
+        push(@params, $offset);
     }
+    my $sth = $dbh->prepare_cached($query);
+    $sth->execute(@params);
+    my $results = $sth->fetchall_arrayref({});
     $sth->finish();
     return $results;
 }
@@ -814,20 +817,25 @@ sub GetImportBibliosRange {
     my ($batch_id, $offset, $results_per_group) = @_;
 
     my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare_cached("SELECT title, author, isbn, issn, import_record_id, record_sequence,
-                                           matched_biblionumber, status, overlay_status
+    my $query = "SELECT title, author, isbn, issn, import_record_id, record_sequence,
+                                           status, overlay_status
                                     FROM   import_records
                                     JOIN   import_biblios USING (import_record_id)
                                     WHERE  import_batch_id = ?
-                                    ORDER BY import_record_id LIMIT ? OFFSET ?");
-    $sth->bind_param(1, $batch_id);
-    $sth->bind_param(2, $results_per_group);
-    $sth->bind_param(3, $offset);
-    my $results = [];
-    $sth->execute();
-    while (my $row = $sth->fetchrow_hashref) {
-        push @$results, $row;
+                                    ORDER BY import_record_id";
+    my @params;
+    push(@params, $batch_id);
+    if($offset){
+        if($results_per_group){
+            $query .= " LIMIT ?";
+            push(@params, $results_per_group);
+        }
+        $query .= " OFFSET ?";
+        push(@params, $offset);
     }
+    my $sth = $dbh->prepare_cached($query);
+    $sth->execute(@params);
+    my $results = $sth->fetchall_arrayref({});
     $sth->finish();
     return $results;
 
-- 
1.6.0.4




More information about the Koha-patches mailing list