[Koha-bugs] [Bug 9659] Undefined authorised value category yields empty dropdown menu on SQL reports

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Feb 22 15:09:22 CET 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9659

Frédéric Demians <frederic at tamil.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |frederic at tamil.fr

--- Comment #10 from Frédéric Demians <frederic at tamil.fr> ---
This function is sub-optimal:

sub IsAuthorisedValueCategory {
    my $category = shift;
    my $categories_arrayref = GetAuthorisedValueCategories();

    foreach my $tmp_category (@$categories_arrayref) {
        if ( $tmp_category eq $category ) {
            return 1;
        }
    }

    return 0;
}

You call GetAuthorisedValueCategories which do a SELECT DISTINCT on the
whole authorised values table. You may do it directly in SQL:

sub IsAuthorisedValueCategory {
    my $sth = C4::Context->dbh->prepare(
        "SELECT category FROM authorised_values WHERE category=? LIMIT 1");
    $sth->execute(shift);
    $sth->fetchrow ? 1 : 0;
}

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list