Hello everybody!

I would like to link one Model to another by HABTM-joinTables.
That is no problem as long as I link Model A to Model B one time.
But how do I link Model A to Model B for different uses.

I try to explain by an example:

I have a "Shop" (Model A) and I have a "Person" (Model B)
I want to link multiple Persons to a Shop for different uses.

1.) Persons that do buy in this shop (joinTable jobs_persons)
2.) Persons that do want a newsletter from the shop (a second
joinTable newsletter_persons_shops)

The first variant is discussed everywhere.

I tried the following:
class Shop extends AppModel
{
  ...
  var $hasAndBelongsToMany =    array(  'Person' =>
 
array(  'className' => 'Person',
 
'joinTable' => 'persons_shops',
 
'foreignKey' => 'shop_id',
 
'associationForeignKey'=> 'person_id',
 
'conditions' => '',
 
'order' => '',
 
'limit' => '',
 
'unique' => true,
 
'finderQuery' => '',
 
'deleteQuery' => '',
                                                                                
                ),
 
'NewsletterPerson' =>
 
array(  'className' => 'Person',
 
'joinTable' => 'newsletter_persons_shops',
 
'foreignKey' => 'shop_id',
 
'associationForeignKey'=> 'person_id',
 
'conditions' => '',
 
'order' => '',
 
'limit' => '',
 
'unique' => true,
 
'finderQuery' => '',
 
'deleteQuery' => '',
                                                                                
                ),
                                                                );

}

On reading the data of the Shop this seems to work.
But is this the right way to do it?

And how do I define the Linking in the "Person"-Model?

var $hasAndBelongsToMany =      array(  'Shop' =>
 
array(  'className' => 'Shop',
 
'joinTable' => 'persons_shops',
 
'foreignKey' => 'person_id',
 
'associationForeignKey'=> 'shop_id',
 
'conditions' => '',
 
'order' => '',
 
'limit' => '',
 
'unique' => true,
 
'finderQuery' => '',
 
'deleteQuery' => '',
                                                                                
                ),
... ??? ...

I hope anybody understands my question :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to