>>>>> "Ask" == Ask Bjørn Hansen <[EMAIL PROTECTED]> writes:
Ask> Hi, Ask> With CDBI I'd often use the "trigger" system to update/maintain Ask> "created_on" and "last_updated" fields. Ask> With RDBO we've so far just used "TIMESTAMP" columns, but now we have Ask> a table where we need to keep track of both when the entry was Ask> created and when it was last updated. MySQL can't do that Ask> automatically, so now I'd like to make RDBO do it. Ask> What'd be the best way? Passing along the answer I got to that very question via IRC... I added the following to my row class: sub insert { my $self = $_[0]; $self->created(DateTime->now) unless $self->created; $self->modified(DateTime->now) unless $self->modified; goto &{$self->can("SUPER::insert")}; } sub update { my $self = $_[0]; $self->modified(DateTime->now); goto &{$self->can("SUPER::update")}; } Seems to work just fine... however, it doesn't permit my userland code to set a forced value for 'modified' (since the code here is always setting it). I was trying to think through a solution to that and didn't come up with one. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object