View | Details | Raw Unified | Return to bug 7846
Collapse All | Expand All

(-)a/C4/Creators/Lib.pm (-13 / +3 lines)
Lines 263-270 NOTE: Do not pass in the keyword 'WHERE.' Link Here
263
sub get_batch_summary {
263
sub get_batch_summary {
264
    my %params = @_;
264
    my %params = @_;
265
    my @batches = ();
265
    my @batches = ();
266
    my $query = "SELECT DISTINCT batch_id FROM creator_batches WHERE creator=?";
266
    my $query = "SELECT batch_id,count(batch_id) as _item_count FROM creator_batches WHERE creator=?";
267
    $query .= ($params{'filter'} ? " AND $params{'filter'};" : ';');
267
    $query .= ($params{'filter'} ? " AND $params{'filter'}" : '');
268
    $query .= " GROUP BY batch_id";
268
    my $sth = C4::Context->dbh->prepare($query);
269
    my $sth = C4::Context->dbh->prepare($query);
269
#    $sth->{'TraceLevel'} = 3;
270
#    $sth->{'TraceLevel'} = 3;
270
    $sth->execute($params{'creator'});
271
    $sth->execute($params{'creator'});
Lines 272-288 sub get_batch_summary { Link Here
272
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
273
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
273
        return -1;
274
        return -1;
274
    }
275
    }
275
    ADD_BATCHES:
276
    while (my $batch = $sth->fetchrow_hashref) {
276
    while (my $batch = $sth->fetchrow_hashref) {
277
        my $query = "SELECT count(batch_id) FROM creator_batches WHERE batch_id=? AND creator=?;";
278
        my $sth1 = C4::Context->dbh->prepare($query);
279
        $sth1->execute($batch->{'batch_id'}, $params{'creator'});
280
        if ($sth1->err) {
281
            warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
282
            return -1;
283
        }
284
        my $count = $sth1->fetchrow_arrayref;
285
        $batch->{'_item_count'} = @$count[0];
286
        push(@batches, $batch);
277
        push(@batches, $batch);
287
    }
278
    }
288
    return \@batches;
279
    return \@batches;
289
- 

Return to bug 7846