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 |
- |
|
|