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

(-)a/C4/Biblio.pm (-1 / +2 lines)
Lines 1081-1086 sub GetBiblioItemInfosOf { Link Here
1081
1081
1082
    my $biblioitemnumber_values = @biblioitemnumbers ? join( ',', @biblioitemnumbers ) : "''";
1082
    my $biblioitemnumber_values = @biblioitemnumbers ? join( ',', @biblioitemnumbers ) : "''";
1083
1083
1084
    my $dbh = C4::Context->dbh;
1084
    my $query = "
1085
    my $query = "
1085
        SELECT biblioitemnumber,
1086
        SELECT biblioitemnumber,
1086
            publicationyear,
1087
            publicationyear,
Lines 1088-1094 sub GetBiblioItemInfosOf { Link Here
1088
        FROM biblioitems
1089
        FROM biblioitems
1089
        WHERE biblioitemnumber IN ($biblioitemnumber_values)
1090
        WHERE biblioitemnumber IN ($biblioitemnumber_values)
1090
    ";
1091
    ";
1091
    return get_infos_of( $query, 'biblioitemnumber' );
1092
    return $dbh->selectall_hashref($query, 'biblioitemnumber');
1092
}
1093
}
1093
1094
1094
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
1095
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 1204-1210 sub GetItemInfosOf { Link Here
1204
        FROM items
1204
        FROM items
1205
        WHERE itemnumber IN ($itemnumber_values)
1205
        WHERE itemnumber IN ($itemnumber_values)
1206
    ";
1206
    ";
1207
    return get_infos_of( $query, 'itemnumber' );
1207
    return $dbh->selectall_hashref($query, 'itemnumber');
1208
}
1208
}
1209
1209
1210
=head2 GetItemsByBiblioitemnumber
1210
=head2 GetItemsByBiblioitemnumber
(-)a/C4/Koha.pm (-49 lines)
Lines 656-709 sub getFacets { Link Here
656
    return $facets;
656
    return $facets;
657
}
657
}
658
658
659
=head2 get_infos_of
660
661
Return a href where a key is associated to a href. You give a query,
662
the name of the key among the fields returned by the query. If you
663
also give as third argument the name of the value, the function
664
returns a href of scalar. The optional 4th argument is an arrayref of
665
items passed to the C<execute()> call. It is designed to bind
666
parameters to any placeholders in your SQL.
667
668
  my $query = '
669
SELECT itemnumber,
670
       notforloan,
671
       barcode
672
  FROM items
673
';
674
675
  # generic href of any information on the item, href of href.
676
  my $iteminfos_of = get_infos_of($query, 'itemnumber');
677
  print $iteminfos_of->{$itemnumber}{barcode};
678
679
  # specific information, href of scalar
680
  my $barcode_of_item = get_infos_of($query, 'itemnumber', 'barcode');
681
  print $barcode_of_item->{$itemnumber};
682
683
=cut
684
685
sub get_infos_of {
686
    my ( $query, $key_name, $value_name, $bind_params ) = @_;
687
688
    my $dbh = C4::Context->dbh;
689
690
    my $sth = $dbh->prepare($query);
691
    $sth->execute( @$bind_params );
692
693
    my %infos_of;
694
    while ( my $row = $sth->fetchrow_hashref ) {
695
        if ( defined $value_name ) {
696
            $infos_of{ $row->{$key_name} } = $row->{$value_name};
697
        }
698
        else {
699
            $infos_of{ $row->{$key_name} } = $row;
700
        }
701
    }
702
    $sth->finish;
703
704
    return \%infos_of;
705
}
706
707
=head2 get_notforloan_label_of
659
=head2 get_notforloan_label_of
708
660
709
  my $notforloan_label_of = get_notforloan_label_of();
661
  my $notforloan_label_of = get_notforloan_label_of();
710
- 

Return to bug 17846