Re: [CDBI] meta_info and mapping tables
[prev]
[thread]
[next]
[Date index for 2005/11/09]
On 9 Nov 2005, at 18:11, Bill Moseley wrote:
> With a link table "Role" that links films and actors
>
> Role->columns(Primary => qw/film actor/);
> Role->has_a(film => 'Film');
> Role->has_a(actor => 'Actor');
>
>
> Then for File->meta_info('has_many', 'actor'):
>
>
> 'actors' => bless( {
> 'foreign_class' => 'Role',
> 'name' => 'has_many',
> 'args' => {
> 'mapping' => [
> 'actor'
> ],
> 'foreign_key' => 'film',
> 'order_by' => undef
> },
> 'class' => 'Film',
> 'accessor' => 'actors'
>
>
> Is the mapping array always a single element for normal link tables
> (linking two tables)?
Normally, yes.
> Or rather, when would the mapping array contain more than a single
> element?
If you supply a list:
Film->has_many( 'actors', [ 'Role' => 'actor', 'flatter' ] );
Each method will be called on the result of the last, so in this case
you'd get back the results of calling $role->actor->flatter.*
I suppose we could think of cases where it _might_ be useful to get
back something that the actor has_a:
Film->has_many( 'cast_pictures', [ 'Role' => 'actor' => 'image' ] );
but I doubt that it would be a good idea to rely on the functionality.
best
will
* I am married to an actor and know this to be a wise course
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
|
|
Re: [CDBI] meta_info and mapping tables
William Ross 18:28 on 09 Nov 2005
|