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

(-)a/C4/Reports/Guided.pm (-8 / +12 lines)
Lines 418-431 sub get_criteria { Link Here
418
418
419
sub nb_rows {
419
sub nb_rows {
420
    my $sql = shift or return;
420
    my $sql = shift or return;
421
    my $sth = C4::Context->dbh->prepare($sql);
421
422
    $sth->execute();
422
    my $derived_name = 'xxx';
423
    my $n = 0;
423
    # make sure the derived table name is not already used
424
    # Loop through the complete results, fetching 1,000 rows at a time.  This
424
    while ( $sql =~ m/$derived_name/ ) {
425
    # lowers memory requirements but increases execution time.
425
        $derived_name .= 'x';
426
    while (my $rows = $sth->fetchall_arrayref(undef, 1000)) {
427
        $n += @$rows;
428
    }
426
    }
427
    my $sth = C4::Context->dbh->prepare(qq{
428
        SELECT COUNT(*) FROM
429
        ( $sql ) $derived_name
430
    });
431
    $sth->execute();
432
    my $n = $sth->fetch->[0];
433
429
    return $n;
434
    return $n;
430
}
435
}
431
436
432
- 

Return to bug 23624