X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=admin%2Fitemtypes.pl;h=3219da340ebe4a23bf56a8c632b4da5b8e562597;hb=e8daace29fc72921e0bbee0df9437d3e9e97642e;hp=1a33a219c5276b9994d8cd590821f9ac29a67afd;hpb=ef8171ba425f766b67d9e139194b6a8d570e301e;p=koha_fer diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 1a33a219c5..3219da340e 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -188,15 +188,17 @@ elsif ( $op eq 'add_validate' ) { # called by default form, used to confirm deletion of data in DB } elsif ( $op eq 'delete_confirm' ) { - # Check both categoryitem and biblioitems, see Bug 199 - my $total = 0; - for my $table ('biblioitems') { - my $sth = - $dbh->prepare( - "select count(*) as total from $table where itemtype=?"); - $sth->execute($itemtype); - $total += $sth->fetchrow_hashref->{total}; - } + # Check both items and biblioitems + my $sth = $dbh->prepare(' + SELECT COUNT(*) AS total FROM ( + SELECT itemtype AS t FROM biblioitems + UNION + SELECT itype AS t FROM items + ) AS tmp + WHERE tmp.t=? + '); + $sth->execute($itemtype); + my $total = $sth->fetchrow_hashref->{'total'}; my $sth = $dbh->prepare(