In addition to additional_base_classes, as recommended earlier, you can also just declare packages and subs after building the loader. Here is a trimmed-down example of my database.pl script, this is pre-loaded by mod_perl so that my website (which is HTML::Mason based) will have access to all the database objects it needs. In this snippet of code the classes JSK::Tag and JSK::Software are generated by Class::DBI::Loader from the tag and software tables in the database.

use Class::DBI::Loader; use Data::Dumper; my $loader = Class::DBI::Loader->new( dsn => 'DBI:Pg:dbname=jasonk', user => 'jasonk', password => 'yeah, right, I'll leave this in, sure', relationships => 1, options => { AutoCommit => 1 }, additional_classes => [qw(Class::DBI::AbstractSearch)], additional_base_classes => [qw(JSK::DBUtils)], ); # calling additional Class::DBI functions on the generated # classes is easy JSK::Tag->columns(Stringify => qw(tag)); # This package is for additional_base_classes, I don't # have a table called 'dbutils', but all the generated # Class::DBI tables inherit from this package. package JSK::DBUtils; use strict; use warnings; use Carp qw(croak); sub some_cool_db_function { ... } # The JSK::Software package is initially generated by # Class::DBI::Loader to go with the 'software' table # in the database, this just adds methods to that class package JSK::Software; use strict; use warnings; sub released { my $self = shift; return defined $self->release_date; }

We're not surrounded, we're in a target-rich environment!

In reply to Re: Class::DBI::Loader and transactions by jasonk
in thread Class::DBI::Loader and transactions by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.