开发者

Moving from Class::DBI to DBIx::Class

开发者 https://www.devze.com 2022-12-21 23:50 出处:网络
I\'m currently doing 开发者_如何学JAVAsome research on DBIx::Class in order to migrate my current application from Class::DBI. Honestly I\'m a bit disappointed about the DBIx::Class when it comes to c

I'm currently doing 开发者_如何学JAVAsome research on DBIx::Class in order to migrate my current application from Class::DBI. Honestly I'm a bit disappointed about the DBIx::Class when it comes to configuring the result classes, with Class::DBI I could setup metadata on models just by calling the on function without a code generator and so on my question is ... can I the same thing with DBIX::Class also it seems that client-side triggers are not supported in DBIx::Class or i'm not looking at the wrong docs?


Triggers can be implemented by redefining the appropriate method (new/create/update/delete etc) in the Result class, and calling the parent (via $self->next::method()) within it, either before or after your code. Admittedly it's a bit clumsy compared to the before/after triggers in Class::DBI.

As for metadata - are you talking about temporary columns on an object? i.e. data that won't be stored in the database row. These can be added easily using one of the Class::Accessor::* modules on CPAN

One of the hardest changes to make when switching from CDBI to DBIC is to think in terms of ResultSets - often what would have been implemented via a Class method in CDBI becomes a method on a ResultSet - and code may need to be refactored considerably, it's not always a straightforward conversion from one to the other.

0

精彩评论

暂无评论...
验证码 换一张
取 消