Relationship(3pm)
π NAME π
Okay bestie, welcome to the Relationship(3pm) page β a User Contributed Perl Documentation moment. The module is Class::DBI::Loader::Relationship, and its whole vibe is: Easier relationship specification in CDBI::L β¨
β¨ SYNOPSIS β¨
Start with the module and a loader, like this:
use Class::DBI::Loader::Relationship;
my $loader = Class::DBI::Loader->new( dsn => "mysql:beerdb",
namespace => "BeerDB");
So instead of spelling out this whole stack of relationship declarations:
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' ]);
You can just say:
$loader->relationship( "a brewery produces beers" );
$loader->relationship( "a pub has beers on handpumps" );
Slay. That's the whole point. π«Ά
πΈ DESCRIPTION πΈ
This module acts as a mix-in, adding the relationship method to Class::DBI::Loader. And because Class::DBI::Loader already knows how to map between table names and class names, there ought to be no need to replicate the names. Iconic behavior, honestly. π
Also β and this is common but not universal β people often want reverse relationships defined for has-many relationships, and they want has-a relationships defined for the linkages surrounding a many-to-many table. So the aim of CDBIL::Relationship is to simplify the declaration of common database relationships by providing both of these features. Periodt. π
The relationship method takes a string. It recognises table names β singular or plural, for convenience β and extracts them from the βsentence.β Cute, clever, no cap. π¦
π AUTHOR π
Simon Cozens, simon@cpan.org π
π¦ SEE ALSO π¦
Class::DBI::Loader. Go peek, bestie. π
Mwah π β signed off with perl v5.36.0, dated 2022-12-12, and yes, the manual name is Relationship(3pm). Bye bestie, go declare some relationships. ππ
π¦ where this page comes from
- debian bookworm: libclass-dbi-loader-relationship-perl 1:1.2-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libclass-dbi-loader-relationship-perl 1:1.2-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libclass-dbi-loader-relationship-perl 1:1.2-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-dbi-loader-relationship-perl 1:1.2-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-dbi-loader-relationship-perl 1:1.2-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms