DBIx::Class::Result::ExternalAttributeThe great new DBIx::Class::Result::ExternalAttribute! | |
Download |
DBIx::Class::Result::ExternalAttribute Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Publisher Name:
- Nicolas Oudard
- Publisher web site:
- http://search.cpan.org/~noudard/
DBIx::Class::Result::ExternalAttribute Tags
DBIx::Class::Result::ExternalAttribute Description
The great new DBIx::Class::Result::ExternalAttribute! DBIx::Class::Result::ExternalAttribute is a Perl module.SYNOPSISuse attached model to store attribute.for example artist result: package t::app::Main::Result::Artist; use base qw/DBIx::Class::Core/; __PACKAGE__->table('artist'); __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, "name", { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }); __PACKAGE__->set_primary_key('id'); __PACKAGE__->load_components(qw/ Result::ExternalAttribute Result::ColumnData /); __PACKAGE__->init_external_attribute( artist_attribute => 't::app::Main::Result::ArtistAttribute', 'artist_id' ); __PACKAGE__->register_relationships_column_data();use a artist attribute result: package t::app::Main::Result::ArtistAttribute; use base qw/DBIx::Class::Core/; __PACKAGE__->table('artist_attribute'); __PACKAGE__->add_columns( "artist_id", { data_type => "integer", is_nullable => 0 }, "year_old", { data_type => "integer", is_nullable => 1}); __PACKAGE__->set_primary_key('artist_id'); __PACKAGE__->load_components(qw/ Result::ColumnData /); __PACKAGE__->belongs_to( artist => "t::app::Main::Result::Artist", 'artist_id'); 1;with this configuration, you can call methods: $artist->get_column_data => get only columns of artist result $artist->get_column_data_with_attribute => get columns of Artist and ArtistAttribute result except artist_id #update with artist attributes $artist->update({name => "Me", year_old => 15}); #create with artist attributes my $rh = t::app::Main::Result::Artist->prepare_params_with_attribute({name => "Me", year_old => 15}); $schema->resultset('Artist')->create($rh); Requirements: · Perl
DBIx::Class::Result::ExternalAttribute Related Software