The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Fry::Lib::CDBI::Load - Sets up a Class::DBI connection and basic variables expected by any Class::DBI library.

DESCRIPTION

This module sets up a Class::DBI connection either using Class::DBI::Loader or with an explicit &set_db call. When the flag CDBI_Loader is set, this class sets up via Class::DBI::Loader. Both paths have the following in common:

        The class variable $cdbi_class allows you to specify your own subclass.
        My::CDBI subclasses $cdbi_class and is the calling class for Class::DBI methods.
                

Since Class::DBI doesn't currently return columns in their table's order, the column orders are fetched every time a new table is defined unless the flag get_columns isn't set. My::CDBI contains the methods for getting the correct column orders for three databases: postgres,mysql and sqlite. If you'd like your database to have correct column_orders, send me an email with the method to do so.

My::CDBI also contains &search_regex which searches with a regex operator (only for mysql and postgresql).

PUBLIC METHODS

        setupCdbi(): Decides to setup Class::DBI through Class::DBI::Loader or normally
        init_columns(%arg): Initializes the variables columns and action_columns
        initCdbiLoader(%arg): Sets up a Class::DBI connection via
                Class::DBI::Loader. The keys to arguments can be pwd, user,db,dbname,
                table and set_db_opts which mean the same as the Library variables.
        newCdbiTable(): Initializes Class::DBI methods for a new connection.
        newTable($table): Called every time a class changes. 

Library Variables

        user($): database user
        pwd($): database password
        db($): database management system (dbms) ie mysql,postgres,sqlite
        dbname($): database name        
        table($): table name
        columns(\@): column names
        action_columns(\@): columns selected for an action such as printing columns, replacing or updating
        set_db_opts(\%): options passed as hashref to Class::DBI's &set_db
        db_default(\%): defaults specific to dbms
        table_class($): Class::DBI class for current table, is My::CDBI for normal
                connections or an automatic name generated from Class::DBI::Loader

OPTIONS

Setting Columns with Option C

This option quickly specifes which columns to view by column numbers. Columns are numbered in their order in a table. To view a numbered list of the current table's columns type 'print_columns'. For a table with columns (id,name,author,book,year):

        -c=1-3  : specifies columns id,name,author
        -c=1,4  : specifies columns id,book  
        -c=1-2,5 : specifies columns id,name,year

Setting Table with Option t

Since a Class::DBI class maps to one table, Class::DBI methods and most commands act on that table. To change the implicit table used by most commands use the option t.

        `-t=animals s type=hairy smells=decent`

TO DO

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.