Fotango Ltd
and 1 contributors

NAME

Locale::Object::DB - do database lookups for Locale::Object modules

DESCRIPTION

This module provides common functionality for the Locale::Object modules by doing lookups in the database that comes with them (which uses DBD::SQLite).

SYNOPSIS

    use Locale::Object::DB;
    
    my $db = Locale::Object::DB->new();
    
    my $table = 'country';
    my $what  = 'name';
    my $value = 'Afghanistan';
    
    my @results = $db->lookup($table, $what, $value);

    my %countries;
    
    $table = 'continent';
    my $result_column = 'country_code';
    
    my $results = $db->lookup(
                              table         => $table, 
                              result_column => $result_column, 
                              search_column => $what, 
                              value         => $value
                             );
                                           
    foreach my $item (@{$results})
    {
      print $item->{$result_column};
    }

    $result = $db->lookup_dual(
                               table      => $table, 
                               result_col => $result_column, 
                               col_1      => $first_search_column, 
                               val_1      => $first_search_value,
                               col_2      => $second_search_column,
                               val_2      => $second_search_value
                              );
    

METHODS

lookup()

    $db->lookup(
                table         => $table,
                result_column => $result_column,
                search_column => $search_column,
                value         => $value
               );
    

lookup will return a reference to an anonymous array of hashes. The hashes will contain the results for a query of the database for cells in $result_column in $table that are in a row that has $value in $search_column. Use '*' as a value for result_column if you want to retrieve whole rows.

For information on what db tables are available and where the data came from, see docs/database.pod.

IMPORTANT: The way of using this method has changed as of version 0.2, and in addition it supersedes the place formerly taken by lookup_all(). Apologies for any inconvenience.

lookup_dual()

    my $result = $db->lookup_dual(
                                  table      => $table, 
                                  result_col => $result_column, 
                                  col_1      => $first_search_column, 
                                  val_1      => $first_search_value,
                                  col_2      => $second_search_column,
                                  val_2      => $second_search_value
                                 );

lookup_dual will return a reference to an anonymous array of hashes. The hashes will contain the results for a query of the database for cells in $result_column in $table that are in a row that has two specified values in two specified columns. Use '*' as a value for $result_column if you want to retrieve whole rows.

NOTES

The database file itself is named locale.db and must reside in the same directory as this module. If it's not present, the module will croak with a fatal error.

AUTHOR

Earle Martin <EMARTIN@cpan.org>

http://purl.oclc.org/net/earlemartin/

CREDITS

See the credits for Locale::Object.

LEGAL

Copyright 2003-2004 Fotango Ltd. All rights reserved. http://opensource.fotango.com/

This module is released under the same license as Perl itself, and is provided on an "as is" basis. The author and Fotango Ltd make no warranties of any kind, either expressed or implied, as to the accuracy and/or utility of any results obtained from its use. However, if you do find something wrong with the results, please let the author know. Thanks.