[Dbix-class] Example confusion -- my own
Ash Berlin
ash at cpan.org
Thu Jun 22 23:32:59 CEST 2006
Alex Beamish wrote:
>
> So join => 'tracks' doesn't mean join to the `tracks' table, it means
> join to the `tracks' relationship, which happens to exist on the
> `track' table. Just like in the first example you gave `cd' didn't
> refer to a table, it referred to a relationship that just so happened
> to be named the same as the table.
>
>
> So does DBIx::Class drop the trailing 's' and look for the first
> relationship in the other table?
>
> The problem I'm having is that 'tracks' is in the Perl code, but
> 'tracks' doesn't appear anywhere in the database, just 'track'. From
> the database:
>
No.
When you say join on tracks, it uses the relationship "tracks", which in
the case of the tutorial is defined via
__PACKAGE__->has_many('tracks' => 'MyDatabase::Main::Track');
So, it then goes to MyDatabase::Main::Track and finds out what table that referes to, which in this case is "track"
Any clearer?
Ash
More information about the Dbix-class
mailing list