NAME
CDBI::BDBI.pm - A subclass of Class::DBI containing several class data to be used by most Class::DBI libraries.
NOTES
This module contains functions necessary to load other Class::DBI libraries. The only necessary one when setting up a database connection is &db_columns. See the samples directory for more detail. An extra Class::DBI search function, &search_regex, is provided which evidently searches with a regex operator (only for mysql and postgresql). I also temporarily copied methods that obtain a table's columns for mysql,postgresql and sqlite from their Class::DBI::* extensions.
Class Methods
- setdb()
- setdb(\%options)
-
This method is a wrapper around Class::DBI's &set_db, it's table and column declarations and &db_columns. You can specify defaults for any of the below options in a library config file. That way when you pass options to &setdb only the defaults are overidden.
%options can include any of the following as keys:
user($): username pwd($): password dbname($): database name db($): database management system choices are: mysql,postgres,sqlite tb($): table name cols(\@): column names db_opts(\%): options passed as hashref to Class::DBI's &set_db __PACKAGE__->setdb({tb=>'kings',db=>'mysql');
This method currently supports mysql,postgresql and sqllite.
- db_columns($database,table)
-
Sets the &cols accessor which keeps a table's columns in order (which seems to be a problem with Class::DBI's &columns accessor). Afterwards, sets &printcols accessor which are columns to be manipulated by user for display purposes usually.
Global data
Here's a brief list of this module's global data
Note: datum with a * next to it must be defined for a Class::DBI library to work.
user($): database user
pwd($): database password
db($): database management system (dbms) ie mysql,postgres,sqlite
dbname($): database name
*tb($): table name
*cols(\@): column names
*printcols(\@):
db_opts(\%): options passed as hashref to Class::DBI's &set_db
_db_default(\%): defaults specific to dbms
TO DO
This module will eventually incorporate loading tables via Class::DBI::Loader in order to switch tables within the shell.
An easier and more universal DBI or SQL way of obtaining a table's columns.
AUTHOR
Me. Gabriel that is. If you want to bug me with a bug: cldwalker@chwhat.com If you like using perl,linux,vim and databases to make your life easier (not lazier ;) check out my website at www.chwhat.com.
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.