[CDBI] How do I add a method to a loaded class?
alex at basespace.net
Sun Aug 7 15:41:29 BST 2005
----- Original Message -----
From: John Beppu
To: Alex Aminoff
Cc: classdbi at lists.digitalcraftsmen.net
Sent: Sunday, August 07, 2005 12:13 AM
Subject: Re: [CDBI] How do I add a method to a loaded class?
On 8/6/05, Alex Aminoff <alex at basespace.net> wrote:
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 ).
Let's step back a bit. Why do you need to have the calcfield() method appear as a column? Isn't it enough that you managed to put the method into the MyTable namespace and are able to call it?
I want to generate an html table screen of the data, using Class::DBI::Plugin::HTML, which appears to rely on ->columns() to find out what columns should be displayed. Yes, one could just list the columns explicitly, but that defeats the elegance of not having to do so; plus, if I change my database schema in mysql, I dont want to have to sync up changes in my perl code.
I'm not actually using Class:DBI::Plugin::HTML, but rather my own module which will work with HTML::Template, just because that is what I'm familiar with already, but the principle is the same.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ClassDBI