Hello,

I just started playing with Cake yesterday and am trying to set up a
self referential many to many relationship using an example of users/
friends that is common to most social networks.  To set up the DB I
created two tables; users with id and username, and friends with
user_id and friend_id (both keys that reference users.id).  As of now,
I am playing in scaffolding and have defined my user model as follows:

<?php

class User extends AppModel
{
        var $name = 'User';

        var $hasAndBelongsToMany = array('Friend' =>
                                                             array('className' 
=> 'User',
                                                                     
'joinTable' => 'users_friends',
                                                                     
'foreignKey' => 'user_id',
                                                                     
'associationForeignKey' =>
'friend_id',                                                                    
                                        'conditions' =>
'',                                                                             
                                                                                
'order' => '',                                                                  
                                                                                
'limit' =>
'',                                                                             
                                                                        
'unique' =>
'true',                                                                         
                                                                                
'finderQuery' =>
'',                                                                             
                                                                                
'deleteQuery' => ''
                                                                                
                                                                ),

                                                                                
                                        );
}

?>


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