I have some perfectly functional code which uses Class::DBI, but I find it a bother to maintain because fields are added to the database with some frequency.

I decided to try Class::DBI::Loader but have run in to a problem with transactions. When I was using Class::DBI, I simply defined a routine do_transaction() as suggested in the documentation, and this was inherited by all my table classes. However, with Class::DBI::Loader, the table classes are automatically created and don't inherit my code.

I solved this by creating a second package in the file, which contained the do_transaction() routine, and describing it as an additional_base_class. This seems to work, but I'm not sure if it was the best way to handle the problem, so I hope that someone with experience using Class::DBI::Loader could tell me how this is usually addressed. The documentation for Class::DBI::Loader is a bit on the skimpy side.

Thank you for your advice.


In reply to 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.