Leo Charre > Metadata-DB > Metadata::DB::Base

Download:
Metadata-DB-1.15.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Metadata::DB::Base

DESCRIPION ^

Base class for some Metadata::DB::* objects.

CONSTRUCTOR ^

new()

Argument is hash ref. You must pass DBH, database handle, to the object. This is a database handle you opened before instancing the object If you wanted to change the name of the table..

   my $m = Metadata::DB::Base({ DBH => $dbh });
   $m->table_metadata_name('other_metadata_table'); # default is 'metadata'
   $m->table_metadata_check; # make sure the table is there, if you wanted to setup

errstr()

May contain message.

SETUP AND DB METHODS ^

dbh()

Returns database handle The DBI handle is passed to the CONSTRUCTOR

table_metadata_exists()

Does the metadata table exist or not? Returns boolean.

table_metadata_create()

Creates metadata table, does not check for existance.

table_metadata_dump()

Optional argument is limit. Returns debug string with a pseudo metadata table dump, suitable for printing to STDERR for debug purposes.

table_metadata_layout()

Returns what the metadata table is expected to look according to current params. Could be useful if you're having a hard time with all of this. If you turn DEBUG to on, this is printed to STDERR .

table_metadata_check()

Create table if not exists.

table_metadata_drop()

Drops metadata table. Erases all records.

table_metadata_reset()

Drops and rebuilds metadata table. Erases all records.

create_index_id()

Creates an index for id col.

create_index()

Args are table name and column name. Mostly meant to be used internal.

table_metadata_last_record_id()

Returns the highest record id number in the table. If none, returns undef- check errstr(). This is similar to a last_insert_id procedure, but checks the id.

RECORD METHODS ^

_record_entries_delete()

arg is id deletes all metadata entries for this record from metadata table (does not commit, etc)

_record_entries_count()

arg is id, returns number of record entries in metadata table

_table_metadata_insert()

arg is id, key, val

_table_metadata_insert_multiple()

arg is id and hashref the hash ref is the metadata key value pairs this is mostly used for indexing

   $self->_table_metadata_insert_mutiple(
      5,
      {
         name_first => 'jim',
         name_middle => 'raynor',
         name_last => 'waltzman',
         phone_number => '208-479-1515',
      },
   );

_record_entries_hashref() and record_entries_hashref()

arg is id returns hashref

_find_record_id_via_record_entries_hashref()

Argument is a metadata struct ( a hashref, each element is an anon array with values) or part of one. This attempts to match ONE record.

Used by Metadata::DB::lookup(), for example.

Returns record id. If there is more than one hit, or no hits, returns undef.

   my $record_id = $self->_find_record_id_via_record_entries_hashref({
      first_name => [ 'jimmy' ],
      middle_name => ['jose','mercado'],
   });

   $record_id or print "Did not find, because: ".$self->errstr;

This is probably only meant for a single record and thus reside in Metadata::DB, but.. it takes a struct and returns an id. It could be useful elsewhere, thus it is in Metadata::DB::Base.

CREATE INDEXES ^

This is to VASTLY improve the speeds of searches.

Call method create_index_id() after running an indexing run for example.

DEBUG ^

   $Metadata::DB::DEBUG = 1;

SEE ALSO ^

Metadata::DB Metadata::DB::Indexer Metadata::DB::Search Metadata::DB::WUI Metadata::Base

AUTHOR ^

Leo Charre leocharre at cpan dot org

CAVEATS ^

Still in development Make sure you have the latest versions of DBI and DBD::mysql

BUGS ^

Please contact the AUTHOR for any issues, suggestions, bugs etc.

COPYRIGHT ^

Copyright (c) Leo Charre. All rights reserved.

LICENSE ^

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

This means that you can, at your option, redistribute it and/or modify it under either the terms the GNU Public License (GPL) version 1 or later, or under the Perl Artistic License.

See http://dev.perl.org/licenses/

DISCLAIMER ^

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Use of this software in any way or in any form, source or binary, is not allowed in any country which prohibits disclaimers of any implied warranties of merchantability or fitness for a particular purpose or any disclaimers of a similar nature.

IN NO EVENT SHALL I BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION (INCLUDING, BUT NOT LIMITED TO, LOST PROFITS) EVEN IF I HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

syntax highlighting: