Hub::Data::DBTable - Wrapper for DBI (expecting a MySQL backend)
Part of the Hub Library
use Hub qw(:standard); my $user = mkinst( 'DBTable', 'user' ); $user->select( -cmd => 'get_admin_user' );
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 ;)
do | new | select | update |
insert | refresh | select_all |
Usage: do [options] Usage: do query
Uses the same -cmd and -data processing as select
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.
Usage: new LIST
Parameters are passed to the standard initialization method refresh.
Usage: refresh LIST
Called implictly by new, and when persistent interpreters (such as mod_perl) would have called new.
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.
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.
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)
DESTROY | _esc |
Disconnect nicely.
Ryan Gies
Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.
Copyright (c) 2000-2005 Ryan Gies. All rights reserved.
This file created by on at