On 4/16/07 10:02 AM, Jonathan Vanasco wrote:
> MyRose::Object::Product
>      relationships => [
>          colors => {
>              type        => 'many to many',
>              map_class   => 'MyRose::Object:: Product2Color',
>              map_from  => 'product_id',
>              map_to => 'color_id',
>          },
>      ],
> 
> MyRose::Object::Color
>      relationships => [
>          products => {
>              type        => 'many to many',
>              map_class   => 'MyRose::Object:: Product2Color',
>              map_from  => 'color_id',
>              map_to => 'product_id',
>          },
>      ],

The map_from and map_to parameters take "the name of the 'many to one'
relationship or foreign key...", not the name of a column.  (This allows
multi-column relationships and fks in mapping tables.)

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relat
ionship/ManyToMany.pm#map_from

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relat
ionship/ManyToMany.pm#map_to

So, for example, look in Product2Color and find the name of the fk or rel
that points to a Color object.  The name of that rel or fk is the value for
your map_to param here:

MyRose::Object::Product
     relationships => [
         colors => {
             type           => 'many to many',
             map_class   => 'MyRose::Object:: Product2Color',
             map_to => 'color', # fk or rel name in Product2Color
             ...

> MyRose::Object::Product::Manager
> $results= Rose::DB::Object::Manager->get_objects(
> object_class=> object_class(),
> with_objects=> [  'colors.color'],

Your with_objects arg would just be "colors" here, which would give you zero
or more Color objects hanging off each Product object.

-John



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to