On Tue, 3 Jul 2007, apv wrote:
I never got around to trying Schema::Loader till now. It's terrific. I
swapped out 10 table classes or whatever with one and it works exactly as it
should.
The thing I want to still be able to do is apply a method to all the table
classes, specifically a created field stamp of NOW(). I'm on an older mysql
for this project so I can't use triggers. There are dates before the epoch so
I'm using DATETIME. This is what I want to do--
sub new {
my ( $class, $attrs ) = @_;
$attrs->{created} = \"NOW()" unless $attrs->{created};
$class->next::method($attrs);
}
Is there a way to get that in all the auto-generated table classes without
voodoo? With? Better idea?
Why not use a field type of TIMESTAMP, which in older mysqls (and in new
ones if you hit the right config buttons), always auto-fills with current
date/time when you create a new row.
As for voodoo: Loader has, iirc, an "additional_base_class" config option,
so create a base class and use it?
Jess
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/