Subject: ANNOUNCE: DBIx::Table 0.03
From: David Lowe <[email-masked]>
Date: 1 Dec 1999 15:23:08 GMT
Newsgroups: comp.lang.perl.announce,comp.lang.perl.modules

Recently added to CPAN...

source here:
http://www.cpan.org/modules/by-authors/id/D/DL/DLOWE/DBIx-Table-0.03.tar.gz

homepage & online documentation here:
http://pootpoot.com/~dlowe/DBIx-Table/

----------------------------------------------------------------------------

NAME
       DBIx::Table - Class used to represent DBI database tables.

SYNOPSIS
       To make it useful:

         package SUBCLASS;
         @ISA = qw(DBIx::Table);
         sub describe {
             my($self) = shift;
             $self->{'table'}       = $table_name;
             $self->{'unique_keys'} = [ [ $column, ... ], ... ];
             $self->{'columns'}     = { $col_name => { %col_options },
                                        [ ... ]
                                      };
           [ $self->{'related'}     = { $class_name => { %relationship },
                                        [ ... ]
                                      }; ]
         }

       To use the useful object:

         $table = load SUBCLASS( db      => $dbi_object,
                               [ where   => { $column => $value, ... }, ]
                               [ columns => [ $column1, $column2 ], ]
                               [ index   => $index, ]
                               [ count   => $count, ]
                               [ groupby => $groupby, ]
                               [ orderby => ['+'|'-'] . $column ]);
         $table = create SUBCLASS( db => $dbi_object);

         $new_table  = $table->load_related( type => $classname,
                                             row  => $row,
                                           [ %where_arguments ] );
         $num_rows   = $table->num_rows();
         $query_rows = $table->query_rows();
         $columns    = $table->columns();
         $db         = $table->db();
         $level      = $table->debug_level( [ level => $level ] );
         $value      = $table->get( column => $column, [ row => $row ] );
         $retval     = $table->set( change => { $column => $value, [ ..., ] },
                                    [ row => $row ] );
         $retval     = $table->refresh( columns = [ $column1, $column2 ],
                                        [ row => $row ] );
         $retval     = $table->commit( [ row => $row ] );
         $retval     = $table->remove( [ row => $row ] );
         $count      = $table->count( [ where => { $column => $value, ... } ]

DESCRIPTION
       DBIx::Table is a class designed to act as an abstraction
       layer around a fairly large subset of SQL queries.  It is
       called 'Table' because it is primarily designed such that
       a single subclass provides an object-oriented interface to
       a single database table.  The module is flexible enough,
       though, that it can be used to abstract most any schema in
       a way that is comfortable to the perl coder who is not
       familiar with the underlying schema, or even SQL.

       As the synopsis above points out, this class is not useful
       when simply used by itself.  Instead, it should be
       subclassed.  The subclass follows a particular syntax for
       describing the structure of the table, which the Table
       module uses internally to control its behavior.

       The subclass can then be used to access the underlying
       data, with the Table module taking care of writing the
       actual SQL.  The current version can write SELECT, UPDATE,
       INSERT and DELETE statements.  Depending on the complexity
       of the definition, it can also do joins across multiple
       tables and intelligently load related table objects.

: : : J. David Lowe :: [email-masked] :: http://pootpoot.com : : :
:   "The secret to happiness is short-term, stupid self-interest!"   :
:                                - Calvin, /Calvin and Hobbes/       :
 :: fingerprint: 79 1D 66 9F 35 A1 2D ED   81 98 26 E1 F8 D5 3F 29 ::