[Dbix-class] howto extend dbix::class to automatically updatesecond table

Brandon Black blblack at gmail.com
Thu Apr 5 18:09:03 GMT 2007


On 4/5/07, Hartmaier Alexander <Alexander.Hartmaier at t-systems.at> wrote:
> You can override sub insert or use triggers if your db supports them.
>

Triggers gets my vote.  Anything complicated that goes on with your
database should be shoved down to the database layer if at all
possible.  It simplifies your code, and it enforces these meta-schema
ideals on all other users of your database (future apps that connect
to your app's database, admin tools, even you on the commandline
fixing things up manually).

I take the same approach with complex queries now too.  If its more
than a join or two, I spend some time factoring out a good manual SQL
query for it, and make it into a view with a good descriptive name,
and add the view to my DBIx::Class::Schema just like any other table.
DBIx::Class *has* the power to do a lot of complex things at the Perl
level, but that doesn't mean its always a good design decision to use
it :)

-- Brandon



More information about the Dbix-class mailing list