[Catalyst] Implementing DBIx::Class

Matt S Trout dbix-class at trout.me.uk
Tue Mar 11 04:08:00 GMT 2008


On Mon, Mar 10, 2008 at 12:49:00PM -0700, Emily Heureux wrote:
> Hi, I would REALLY like to implement DBIx::Class for our project that
> currently uses a different database gateway.  I would like to implement it
> slowly if possible, and eventually 'unhook' our project from the old
> gateway.  This is what I would like to do.  Can you tell me if this is
> possible?
> 
>  
> 
> 1)       I am looking at the CatalystBasics tutorial, which I did some time
> ago.  I have a mysql database, and I want to add to the MyAppDB.pm file a
> line like this:  (Notice that I am only adding one table.  Can I just add
> one table to test?)
> 
>  
> 
> __PACKAGE__->load_classes({
>             MyAppDB => [qw/prot/]
>          });
 
Yes.             
 
> 2)       Next, I think I would create a MyAppDB/prot.pm file, and load the
> one table and columns just like in the tutorial.  One question about this:
> Do I have to establish relationships (many_to_many, etc) now, in this file,
> like in the tutorial?

You only need to add them when you need to use them.

DBIC doesn't care if it doesn't know about all your database - it's
designed on the basis you know what you're doing and it doesn't, so you
can lie to it as much as you need to.

> 3)       Then I need to run this line on the command line:  (Can I replace
> 'tutorial' with anything I want?)
> 
>  
> 
> $ script/myapp_create.pl model MyAppDB DBIC::Schema MyAppDB dbi:mysql
> 'tutorial' '' '{ AutoCommit => 1 }'

Yep.

Note that DBIx::Class has its own mailing list (see DBIx::Class POD for
the details) and you'd be best asking DBIC-specific questions (like 1 and 2
here) on there.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list