NAME

Hub::Data::DBTable - Wrapper for DBI (expecting a MySQL backend)

Part of the Hub Library

Top


SYNOPSIS

    use Hub qw(:standard);
    my $user = mkinst( 'DBTable', 'user' );
    $user->select( -cmd => 'get_admin_user' );

Top


DESCRIPTION

This is implemented for access to a database which is defined by

    /sys/dbi/connect/dsn
    /sys/dbi/connect/user
    /sys/dbi/connect/clave

And supported by files

    db-struct.hf
    db-commands.hf

Which make it pretty specific to a runtime web application ;)

Top


METHODS

do new select update
insert refresh select_all
do
Execute an SQL query
 Usage: do [options]
 Usage: do query

Uses the same -cmd and -data processing as select

insert
Insert a record
 Usage: insert -data => \%hash, [options]

options: -nonull Convert undefined (NULL) values to '' -forcenull Convert empty ('') values to undefined (NULL)

Where the keys of the data hash match the column names.

new
Constructor.
 Usage: new LIST

Parameters are passed to the standard initialization method refresh.

refresh
Return instance to initial state.
 Usage: refresh LIST

Called implictly by new, and when persistent interpreters (such as mod_perl) would have called new.

select
Select records from the table
 Usage: select [options]
 Usage: select query

OPTIONS

  -cmd        The command (which is read from db-commands.hf)
  -data       The data used to populate the query

Using the -cmd option allows you to store your SQL queries in the external file ``db-commands.hf'' rather than passing in the query.

select_all
Select all columns from a table
 Usage: select_all -by => \@columns, -using => \%column_to_value_hash
 Usage: select_all [options]

In the first form:

  -by => [ "pkey" ], -using => { pkey => 1001 }

Will build the where clause by extracing the key/val from ``-using'' for each column name in ``-by''.

Or, each option is a WHERE condition. For instance, the option:

  -pkey => 1001

Would add ``WHERE pkey = '1001''' to the select query.

update
Update an existion record
 Usage: update -by => \@names, -set => \@names, -using => \%data, [options]

where: -by Column names for the WHERE clause -set Column names for the SET clause (otherwise all columns) -using Data for -by and -set clauses options: -nonull Convert undefined (NULL) values to '' -forcenull Convert empty ('') values to undefined (NULL)

Top


INTERNAL

DESTROY _esc
DESTROY
Called implicitly by the framework.

Disconnect nicely.

_esc

Top


AUTHOR

Ryan Gies

Top


COPYRIGHT

Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.

Copyright (c) 2000-2005 Ryan Gies. All rights reserved.

Top


UPDATED

This file created by on at

Top