X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass.pm;h=34ab70da69874c5f82815ed3edc81d866a57903c;hb=2eef86336a37040fc939429b1003cd93e7c0a360;hp=3c7933fbfff02c8141cd884598b6d32508df5153;hpb=ade0fe3b2e40703bafbc187c9bdf03fb297319b0;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 3c7933f..34ab70d 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -3,11 +3,12 @@ package DBIx::Class; use strict; use warnings; +use MRO::Compat; + use vars qw($VERSION); use base qw/DBIx::Class::Componentised Class::Accessor::Grouped/; use DBIx::Class::StartupCheck; - sub mk_classdata { shift->mk_classaccessor(@_); } @@ -24,7 +25,7 @@ sub component_base_class { 'DBIx::Class' } # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -$VERSION = '0.08102'; +$VERSION = '0.08108'; $VERSION = eval $VERSION; # numify for warning-free dev releases @@ -72,9 +73,11 @@ Create a schema class called MyDB/Schema.pm: 1; -Create a table class to represent artists, who have many CDs, in +Create a result class to represent artists, who have many CDs, in MyDB/Schema/Result/Artist.pm: +See L for docs on defining result classes. + package MyDB::Schema::Result::Artist; use base qw/DBIx::Class/; @@ -86,7 +89,7 @@ MyDB/Schema/Result/Artist.pm: 1; -A table class to represent a CD, which belongs to an artist, in +A result class to represent a CD, which belongs to an artist, in MyDB/Schema/Result/CD.pm: package MyDB::Schema::Result::CD; @@ -108,9 +111,17 @@ Then you can use these classes in your application's code: # Query for all artists and put them in an array, # or retrieve them as a result set object. + # $schema->resultset returns a DBIx::Class::ResultSet my @all_artists = $schema->resultset('Artist')->all; my $all_artists_rs = $schema->resultset('Artist'); + # Output all artists names + # $artist here is a DBIx::Class::Row, which has accessors + # for all its columns. Rows are also subclasses of your Result class. + foreach $artist (@artists) { + print $artist->name, "\n"; + } + # Create a result set to search for artists. # This does not query the DB. my $johns_rs = $schema->resultset('Artist')->search(