GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::DBI::LOADER::RELATIONSHIP (3)

.ds Aq ’

NAME

Class::DBI::Loader::Relationship - Easier relationship specification in CDBI::Loader

CONTENTS

SYNOPSIS



  use Class::DBI::Loader::Relationship;

  my $loader = Class::DBI::Loader->new( dsn => "mysql:beerdb",
                                        namespace => "BeerDB");



Now instead of saying



    BeerDB::Brewery->has_many(beers => "BeerDB::Beer");
    BeerDB::Beer->has_a(brewery => "BeerDB::Brewery");

    BeerDB::Handpump->has_a(beer => "BeerDB::Beer");
    BeerDB::Handpump->has_a(pub => "BeerDB::Pub");
    BeerDB::Pub->has_many(beers => [ BeerDB::Handpump => beer ]);
    BeerDB::Beer->has_many(pubs => [ BeerDB::Handpump => pub ]);



Just say



    $loader->relationship( "a brewery produces beers" );
    $loader->relationship( "a pub has beers on handpumps" );



And something like ( upgraded in v1.3 )



    MyApp::Page->has_a( author => MyApp::User );
    MyApp::Page->has_many( revisions => MyApp::PageRevision );



Just say



    $loader->relationship( "a page has an user as author" );
    $loader->relationship( "a page has many page_revisions as revisions" );



DESCRIPTION

This module acts as a mix-in, adding the relationship method to Class::DBI::Loader. Since Class::DBI::Loader knows how to map between table names and class names, there ought to be no need to replicate the names.

In addition, it is common (but not universal) to want reverse relationships defined for has-many relationships, and for has-a relationships to be defined for the linkages surrounding a many-to-many table.

The aim of CDBIL::Relationship is to simplify the declaration of common database relationships by providing both of these features.

The relationship takes a string. It recognises table names (singular or plural, for convenience) and extracts them from the sentence.

AUTHOR

Simon Cozens, simon@cpan.org

Chunzi, chunzi@perlchina.org

SEE ALSO

Class::DBI::Loader.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 RELATIONSHIP (3) 2005-11-09

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.