[vienna.pm] [ANNOUNCE] DBIx::Lookup::Field 0.01

Marcel Grunauer marcel at codewerk.com
Sat May 19 06:45:53 CDT 2001


* * * vienna-pm-list * * *


NAME
    DBIx::Lookup::Field - Create a lookup hash from a database table

SYNOPSIS
      use DBI;
      use DBIx::Lookup::Field qw/dbi_lookup_field/;

      $dbh = DBI->connect(...);
      my $inst_id = dbi_lookup_field(
          DBH   => $dbh,
          TABLE => 'institution'
          KEY   => 'name',
          VALUE => 'id',
      );

      print "Inst_A has id ", $inst_id->{Inst_A};

DESCRIPTION
    This module provides a way to construct a hash from a database table.
    This is useful for the situation where you have to perform many lookups
    of a field by using a key from the same table. If, for example, a table
    has an id field and a name field and you often have to look up the name
    by its id, it might be wasteful to issue many separate SQL queries.
    Having the two fields as a hash speeds up processing, although at the
    expense of memory.

EXPORTS
    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).

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

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

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

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

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

BUGS
    None known at this time. If you find any oddities or bugs, please do
    report them to the author.

AUTHOR
    Marcel Grünauer <marcel at codewerk.com>

COPYRIGHT
    Copyright 2001 Marcel Grünauer. All rights reserved.

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

SEE ALSO
    DBI(3pm).


Marcel

-- 
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
 -- London.pm strategy aka "embrace and extend" aka "mark and sweep"
###
You are subscribed to vienna-pm-list as Marcel Grunauer <marcel at codewerk.com>
http://www.fff.at/fff/vienna.pm/



More information about the Vienna-pm mailing list