[Catalyst] Explanation of Catalyst::(Helper)::Model::DBIC::Schema

Tobias t at funkreich.de
Tue Apr 25 12:00:31 CEST 2006


Ok, I admit it: I just don't get how the recommended
Catalyst::Model::DBIC::Schema and its helper modules should be used!

I set up some modules and scripts to try out the schema-based approach
without catalyst and everything worked fine. Here's what I did:

---

package MySchema;
use base qw/DBIx::Class::Schema/;
__PACKAGE__->load_classes( qw/Users/ );
1;

package MySchema::Users;
use base qw/DBIx::Class/;
__PACKAGE__->load_components( qw/PK::Auto Core/ );
__PACKAGE__->table( 'users' );
__PACKAGE__->add_columns( qw/id username password .../ );
__PACKAGE__->set_primary_key( 'id' );
1;

use MySchema;
my $schema = MySchema->connect( '...', '...', '...', { AutoCommit => 1 } );
my $resultset = $schema->resultset( 'Users' )->search( username => 'peter' );
while( my $user = $resultset->next ) {
  print $user->username."\n";
}

---

Works like a charm! Now can please somebody tell me how to use the helper
scripts to create something similar which is usable inside Catalyst? The
manpage of Catalyst::Helper::Model::DBIC::Schema says:

script/myapp_create.pl model Foo DBIC::Schema FooSchema dbi:mysql:foodb myuname
mypass '{ AutoCommit => 1 }'

What does "Foo" mean? Where's the difference between "Foo" and "FooSchema"?
Maybe the wording is a bit misleading here... How do I create the
Schema-Baseclass (MySchema) and the actual models for the tables
(MySchema::Users). Unfortunately catalystframework.org is currently
unavailable.

Thanx for your help!

Toby



More information about the Catalyst mailing list