[Dbix-class] more schema questions
Alan Humphrey
alan.humphrey at comcast.net
Fri Jan 6 18:19:07 CET 2006
I'm trying to take baby steps in getting this working, so I've removed
Catalyst from the equation for the time being. Today's effort is simply
getting a single table read. Following the docs from DBIx::Class::Schema
I've got the following.
Schema:
package BirdWeb::Admin::Model::BirdWebSchema;
use strict;
use base qw/DBIx::Class::Schema/;
__PACKAGE__->load_classes( qw/Birds/ );
1;
Birds:
package BirdWeb::Admin::Model::BirdWebSchema::Birds;
use strict;
use base qw/DBIx::Class/;
__PACKAGE__->load_components( qw/Core/ );
__PACKAGE__->table('birds');
__PACKAGE__->add_columns( qw[id genus_id species_name_id image_id
north_america_map_id
washington_map_id
default_sound_id
default_bird_common_name_id generic_bird_common_name_id
taxonomic_order
identification voice habitat behavior
diet nesting
migration where_found conservation_status
notes] );
__PACKAGE__->set_primary_key( qw[id] );
1;
Database:
package BirdWeb::Admin::Model::DBIC;
use strict;
use BirdWeb::Admin::Model::BirdWebSchema;
my @conn_info = (
'dbi:mysql:BirdWeb',
'user',
'pass',
{ RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel
=> 0 }
);
__PACKAGE__->compose_connection( __PACKAGE__, @conn_info );
__PACKAGE__->load_classes;
1;
Test script:
use Data::Dumper;
my $obj = BirdWeb::Admin::Model::DBIC::Birds->find(234);
print Dumper($obj);
Result:
Can't locate object method "find" via package
"BirdWeb::Admin::Model::DBIC::Birds"
If I 'use' BirdWeb::Admin::Model::DBIC::Birds then there's a compile time
error complaining the module can't be found.
What am I missing?
Thanks!
- Alan
More information about the Dbix-class
mailing list