=back
-If you are also using a L<DBIx::Class::PK::Auto> component, please
-make sure you load it correctly. Refer to
-L<DBIx::Class::PK::Auto/DESCRIPTION> for more information.
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
__PACKAGE__->load_components(qw/Core DB/);
If you want serial/auto-incrementing primary keys, you should use the
-L<DBIx::Class::PK::Auto> component for your database. For example, if
-you're using SQLite add C<PK::Auto::SQLite> to the list:
-
- __PACKAGE__->load_components(qw/PK::Auto::SQLite Core DB/);
+L<DBIx::Class::PK::Auto> component.
+ __PACKAGE__->load_components(qw/PK::Auto Core DB/);
C<PK::Auto> classes exist for many databases; see
L<DBIx::Class::PK::Auto> for more information.
Load any components required by each class with the load_components() method.
This should consist of "Core" plus any additional components you want to use.
-For example, if you use SQLite and want serial/auto-incrementing primary keys:
+For example, if you want serial/auto-incrementing primary keys:
- __PACKAGE__->load_components(qw/ PK::Auto::SQLite Core /);
+ __PACKAGE__->load_components(qw/ PK::Auto Core /);
C<PK::Auto> classes exist for many databases; see
L<DBIx::Class::PK::Auto> for more information.
=head1 SYNOPSIS
- # In your table classes (replace PK::Auto::SQLite with your database)
- __PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
- __PACKAGE__->set_primary_key('id');
+__PACKAGE__->load_components(qw/PK::Auto Core/);
+__PACKAGE__->set_primary_key('id');
=head1 DESCRIPTION
This class overrides the insert method to get automatically incremented primary
keys.
-You don't want to be using this directly - instead load the appropriate one for
-your database, e.g. C<PK::Auto::SQLite>, in your table classes:
+ __PACKAGE__->load_components(qw/PK::Auto Core/);
- __PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
-
-Note that C<PK::Auto::SQLite> is specified as the leftmost argument.
-
-Alternatively, you can load the components separately:
-
- __PACKAGE__->load_components(qw/Core/);
- __PACKAGE__->load_components(qw/PK::Auto::SQLite/);
-
-This can be used, for example, if you have different databases and need to
-determine the appropriate C<PK::Auto> class at runtime.
+Note that C<PK::Auto> is specified as the leftmost argument.
=head1 LOGIC
return $self->schema->source($self->relationship_info($rel)->{source});
}
+=head2 related_class
+
+=head3 Arguments: ($relname)
+
+Returns the class object for the given relationship
+
+=cut
+
+sub related_class {
+ my ($self, $rel) = @_;
+ if( !$self->has_relationship( $rel ) ) {
+ $self->throw_exception("No such relationship '$rel'");
+ }
+ return $self->schema->class($self->relationship_info($rel)->{source});
+}
+
=head2 resultset
Returns a resultset for the given source, by calling:
package Library::Schema::CD;
use base qw/DBIx::Class/;
- __PACKAGE__->load_components(qw/PK::Auto::Pg Core/); # for example
+ __PACKAGE__->load_components(qw/PK::Auto Core/); # for example
__PACKAGE__->table('cd');
# Elsewhere in your code:
=head1 SYNOPSIS
# In your table classes
- __PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
+ __PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->set_primary_key('id');
=head1 DESCRIPTION
use base qw/DBIx::Class/;
-__PACKAGE__->load_components(qw/PK::Auto::SQLite CDBICompat Core DB/);
+__PACKAGE__->load_components(qw/PK::Auto CDBICompat Core DB/);
use File::Temp qw/tempfile/;
my (undef, $DB) = tempfile();