[CDBI] How do I add a method to a loaded class?

Alex Aminoff alex at basespace.net
Sun Aug 7 01:22:28 BST 2005


Very basic newbie question...

I have loaded up my database into a Class::DBI structure using Class::DBI::Loader. Now I would like to add a method to one of the autogenerated classes that will calculate some stuff based on various data, but otherwise appear in most respects like any other column from the DB. I'm pretty sure I want something using MyTable->columns( TEMP => calcfield ).

What I've tried so far, all in one file:

use Class::DBI::Loader;

my $loader = Class::DBI::Loader->new(...);

sub MyTable::calcfield {
 ...
}

MyTable->columns(TEMP => qw/calcfield/);


This compiles, but when I later ask for MyTable->columns(), the new column is not there.

Thanks for any advice,

 - Alex Aminoff
  alex at basespace.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20050806/7b29503f/attachment.htm


More information about the ClassDBI mailing list