It depends on the actual tables you create - ie. are you going to
create a favourite_stores table with additional fields, or will it
just be a join table?

Also, keep in mind you can have more than relationship defined between
the same models...

eg. I would create two join tables:

consumers_favouritestores (id, consumer_id, store_id)
consumers_stores (id, consumer_id, store_id)



And then create the associations via the Consumer model.

var $hasAndBelongsToMany = array(
                'FavouriteStores' => array('className' => 'Store',
                                                                                
                                                'joinTable' => 
'consumers_favouritestores',
                                                                                
                                                'foreignKey' => 'consumer_id',
                                                                                
                                                'associationForeignKey' => 
'store_id'),
                'FrequentedStores' => array('className' => 'Store',
                                                                                
                                                'joinTable' => 
'consumers_stores',
                                                                                
                                                'foreignKey' => 'consumer_id',
                                                                                
                                                'associationForeignKey' => 
'store_id'),
);


In regards to setting up two-way associations, that is entirely up to
your application and how you will be accessing/saving your data. I
recommend starting simple and adding the associations as you find you
need them.

Cheers,
Adam

On Dec 24, 11:55 am, stonez <[EMAIL PROTECTED]> wrote:
> Let's say, I have three models named "stores", "consumers",
> "favorite_stores"
>
> What's the correct association I should declear?
>
> Here's the defination I made:
> - store hasAndBelongsToMany consumers.
> - consumers hasAndBelongsToMany stores.
> - consuemr hasMany favorite_stores.
> - sotre belongsTo favorites_stores.
>
> Are these needed?
> - favorites_stores belongsTo stores.
> - favorites_stores belongsTo consumers.
>
> Stonez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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