On Sun, Mar 1, 2009 at 12:20 PM, mscdex <[email protected]> wrote:
>
> On Mar 1, 5:12 am, "[email protected]" <[email protected]>
> wrote:
>> I have the following 2 tables:
>>
>> users
>> assets
>>
>> each user has many assets, but any users can allow other users to
>> access their assets
>
> You could set up a HasAndBelongsToMany relationship between the two
> models. You would still need to create a third table for this kind of
> relationship though.

I think the OP wants to know how to get around having 2 user_id fields
in the join table. Have a look through here:
http://groups.google.com/group/cake-php/search?group=cake-php&q=self+habtm

I think it should be something along these lines:
in User model

var $hasAndBelongsToMany = array(
        'UserAsset' => array(
                'className' => 'User',
                'joinTable' => 'user_assets',
                'foreignKey' =>  'user_id',
                'associationForeignKey' => 'access_user_id'
        )
);

--~--~---------~--~----~------------~-------~--~----~
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