DBIx-Lookup-Field

 view release on metacpan or  search on metacpan

lib/DBIx/Lookup/Field.pm  view on Meta::CPAN

the two fields as a hash speeds up processing, although at the expense
of memory.

The functions can be exported individually or with the C<:all> tag.

=head1 FUNCTIONS

=head2 dbi_lookup_field()

This function creates a hash from two fields in a database table on a
DBI connection. One field acts as the hash key, the other acts as the
hash value. It expects a parameter hash and returns a reference to the
lookup hash.

The following parameters are accepted. Parameters can be required or
optional. If a required parameter isn't given, an exception is raised
(i.e., it dies).

=over 4

=item DBH

The database handle through which to access the table from which to
create the lookup. Required.

=item TABLE

The name of the table that contains the key and value fields. Required.

=item KEY

The field name of the field that is to act as the hash key. Required.

=item VALUE

The field name of the field that is to act as the hash value. Required.

=item WHERE

A SQL 'WHERE' clause with which to restrict the 'SELECT' statement that
is used to create the hash. Optional.

=back

=head2 dbi_lookup_field_with_reverse()

This function takes the same parameters as C<dbi_lookup_field()> but in
addition to the lookup hash, it also returns a reversed hash where you
can lookup the table keys by the table values.

  my ($lookup, $reverse) = dbi_lookup_field_with_reverse(...);

Note that if a value occurs more than once, only one of the potential
keys will win (the one that occurs first in the lookup hash's key order),
so be warned.

=head1 INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

=head1 BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests through the web interface at
L<http://rt.cpan.org/Public/Dist/Display.html?Name=DBIx-Lookup-Field>.

=head1 AVAILABILITY

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you, or see
L<http://search.cpan.org/dist/DBIx-Lookup-Field/>.

The development version lives at
L<http://github.com/hanekomu/DBIx-Lookup-Field/>.
Instead of sending patches, please fork this project using the standard git
and github infrastructure.

=head1 AUTHOR

  Marcel Gruenauer <marcel@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2001 by Marcel Gruenauer.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.811 second using v1.01-cache-2.11-cpan-5a3173703d6 )