01 Mar 2004 16:52:31 UTC
- Distribution: Class-DBI-Loader-Relationship
- Module version: 1.2
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (922 / 0 / 2)
- KwaliteeBus factor: 0
- 77.78% Coverage
- License: unknown
- Activity24 month
- Download (3.04KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionSIMON Simon Cozens
Why not adopt me?This distribution is up for adoption! If you're interested then please contact the PAUSE module admins via email.
Class::DBI::Loader::Relationship - Easier relationship specification in CDBI::L
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' ]);
$loader->relationship( "a brewery produces beers" ); $loader->relationship( "a pub has beers on handpumps" );
This module acts as a mix-in, adding the
Class::DBI::Loaderknows 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::Relationshipis to simplify the declaration of common database relationships by providing both of these features.
relationshiptakes a string. It recognises table names (singular or plural, for convenience) and extracts them from the "sentence".
Module Install Instructions
To install Class::DBI::Loader::Relationship, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Class::DBI::Loader::Relationship
For more information on module installation, please visit the detailed CPAN module installation guide.