Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class::dbi::relationship(3pm) [debian man page]

Class::DBI::Relationship(3pm)				User Contributed Perl Documentation			     Class::DBI::Relationship(3pm)

Class::DBI::Relationship - base class for Relationships DESCRIPTION
A Class::DBI class represents a database table. But merely being able to represent single tables isn't really that useful - databases are all about relationships. So, Class::DBI provides a variety of Relationship models to represent common database occurences (HasA, HasMany and MightHave), and provides a way to add others. SUBCLASSING
Relationships should inherit from Class::DBI::Relationship, and provide a variety of methods to represent the relationship. For examples of how these are used see Class::DBI::Relationship::HasA, Class::DBI::Relationship::HasMany and Class::DBI::Relationship::MightHave. remap_arguments sub remap_arguments { my $self = shift; # process @_; return ($class, accessor, $foreign_class, $args) } Subclasses should define a 'remap_arguments' method that takes the arguments with which your relationship method will be called, and transforms them into the structure that the Relationship modules requires. If this method is not provided, then it is assumed that your method will be called with these 3 arguments in this order. This should return a list of 4 items: class The Class::DBI subclass to which this relationship applies. This will be passed in to you from the caller who actually set up the relationship, and is available for you to call methods on whilst performing this mapping. You should almost never need to change this. This usually an entire application base class (or Class::DBI itself), but could be a single class wishing to override a default relationship. accessor The method in the class which will provide access to the results of the relationship. foreign_class The class for the table with which the class has a relationship. args Any additional args that your relationship requires. It is recommended that you use this as a hashref to store any extra information your relationship needs rather than adding extra accessors, as this information will all be stored in the 'meta_info'. triggers sub triggers { return ( before_create => sub { ... }, after_create => sub { ... }, ); } Subclasses may define a 'triggers' method that returns a list of triggers that the relationship needs. This method can be omitted if there are no triggers to be set up. methods sub methods { return ( method1 => sub { ... }, method2 => sub { ... }, ); } Subclasses may define a 'methods' method that returns a list of methods to facilitate the relationship that should be created in the calling Class::DBI class. This method can be omitted if there are no methods to be set up. perl v5.12.4 2005-09-16 Class::DBI::Relationship(3pm)

Check Out this Related Man Page

DBIx::Class::CDBICompat(3pm)				User Contributed Perl Documentation			      DBIx::Class::CDBICompat(3pm)

DBIx::Class::CDBICompat - Class::DBI Compatibility layer. SYNOPSIS
package My::CDBI; use base qw/DBIx::Class::CDBICompat/; ...continue as Class::DBI... DESCRIPTION
DBIx::Class features a fully featured compatibility layer with Class::DBI and some common plugins to ease transition for existing CDBI users. This is not a wrapper or subclass of DBIx::Class but rather a series of plugins. The result being that even though you're using the Class::DBI emulation layer you are still getting DBIx::Class objects. You can use all DBIx::Class features and methods via CDBICompat. This allows you to take advantage of DBIx::Class features without having to rewrite your CDBI code. Plugins CDBICompat is good enough that many CDBI plugins will work with CDBICompat, but many of the plugin features are better done with DBIx::Class methods. Class::DBI::AbstractSearch "search_where()" is fully emulated using DBIC's search. Aside from emulation there's no reason to use "search_where()". Class::DBI::Plugin::NoCache "nocache" is fully emulated. Class::DBI::Sweet The features of CDBI::Sweet are better done using DBIC methods which are almost exactly the same. It even uses Data::Page. Class::DBI::Plugin::DeepAbstractSearch This plugin will work, but it is more efficiently done using DBIC's native search facilities. The major difference is that DBIC will not infer the join for you, you have to tell it the join tables. Choosing Features In fact, this class is just a recipe containing all the features emulated. If you like, you can choose which features to emulate by building your own class and loading it like this: package My::DB; __PACKAGE__->load_own_components(qw/CDBICompat/); this will automatically load the features included in My::DB::CDBICompat, provided it looks something like this: package My::DB::CDBICompat; __PACKAGE__->load_components(qw/ CDBICompat::ColumnGroups CDBICompat::Retrieve CDBICompat::HasA CDBICompat::HasMany CDBICompat::MightHave /); LIMITATIONS
Unimplemented The following methods and classes are not emulated, maybe in the future. Class::DBI::Query Deprecated in Class::DBI. Class::DBI::Column Not documented in Class::DBI. CDBICompat's columns() returns a plain string, not an object. data_type() Undocumented CDBI method. Limited Support The following elements of Class::DBI have limited support. Class::DBI::Relationship The semi-documented Class::DBI::Relationship objects returned by "meta_info($type, $col)" are mostly emulated except for their "args" method. Relationships Relationships between tables (has_a, has_many...) must be declared after all tables in the relationship have been declared. Thus the usual CDBI idiom of declaring columns and relationships for each class together will not work. They must instead be done like so: package Foo; use base qw(Class::DBI); Foo->table("foo"); Foo->columns( All => qw(this that bar) ); package Bar; use base qw(Class::DBI); Bar->table("bar"); Bar->columns( All => qw(up down) ); # Now that Foo and Bar are declared it is safe to declare a # relationship between them Foo->has_a( bar => "Bar" ); AUTHORS
Matt S. Trout <> LICENSE
You may distribute this code under the same terms as Perl itself. perl v5.14.2 2011-05-10 DBIx::Class::CDBICompat(3pm)
Man Page

Featured Tech Videos