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

(-)a/C4/Biblio.pm (-1 / +2 lines)
Lines 1052-1057 sub GetBiblioItemInfosOf { Link Here
1052
1052
1053
    my $biblioitemnumber_values = @biblioitemnumbers ? join( ',', @biblioitemnumbers ) : "''";
1053
    my $biblioitemnumber_values = @biblioitemnumbers ? join( ',', @biblioitemnumbers ) : "''";
1054
1054
1055
    my $dbh = C4::Context->dbh;
1055
    my $query = "
1056
    my $query = "
1056
        SELECT biblioitemnumber,
1057
        SELECT biblioitemnumber,
1057
            publicationyear,
1058
            publicationyear,
Lines 1059-1065 sub GetBiblioItemInfosOf { Link Here
1059
        FROM biblioitems
1060
        FROM biblioitems
1060
        WHERE biblioitemnumber IN ($biblioitemnumber_values)
1061
        WHERE biblioitemnumber IN ($biblioitemnumber_values)
1061
    ";
1062
    ";
1062
    return get_infos_of( $query, 'biblioitemnumber' );
1063
    return $dbh->selectall_hashref($query, 'biblioitemnumber');
1063
}
1064
}
1064
1065
1065
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
1066
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
(-)a/C4/Items.pm (-1 / +2 lines)
Lines 1200-1211 sub GetItemInfosOf { Link Here
1200
1200
1201
    my $itemnumber_values = @itemnumbers ? join( ',', @itemnumbers ) : "''";
1201
    my $itemnumber_values = @itemnumbers ? join( ',', @itemnumbers ) : "''";
1202
1202
1203
    my $dbh = C4::Context->dbh;
1203
    my $query = "
1204
    my $query = "
1204
        SELECT *
1205
        SELECT *
1205
        FROM items
1206
        FROM items
1206
        WHERE itemnumber IN ($itemnumber_values)
1207
        WHERE itemnumber IN ($itemnumber_values)
1207
    ";
1208
    ";
1208
    return get_infos_of( $query, 'itemnumber' );
1209
    return $dbh->selectall_hashref($query, 'itemnumber');
1209
}
1210
}
1210
1211
1211
=head2 GetItemsByBiblioitemnumber
1212
=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