Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

kaare (663)

  (email not shown publicly)

Journal of kaare (663)

Thursday March 29, 2007
05:16 AM

DBIx::Class ResultSets

[ #32830 ]

It's easy to do single-table stuff with DBIx::Class. And even more complex actions are well supported, but you risk duplicating your code if you don't watch out.

Especially if you use Catalyst, it's easy to write the same piece of code to fetch or update related tables in several controllers.

This will surely and quickly become a problem.

Some people will have this in the Model layer of Catalyst. It's OK if all your work is guaranteed to be Catalyst. But what if it's not? What if you want to access your database from e.g. a stand alone server or a cron job?

I use DBIC ResultSets to fill out the hole between simple DBIC classes and the actual code I think that RS suits the bill in a nice way.

This is one way to have more complex database code with DBIx::Class. I'm sure there are a lot of other ways to do it. And I'm sure some people will tell me why I'm wrong :-)

But it's easy to do. Just watch.

In Project::DB::Class:

Write methods in Project::RS::Class, e.g.

sub create_full {
        my ( $self, $args_ref ) = @_;


        # Get schema
        my $schema = $self->result_source->schema;

                sub {
                        # Do something

and then use it from your controller, script, whatever:


The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.