On Sep 28, 11:36 pm, red <[EMAIL PROTECTED]> wrote:
> Hello everybody!
> I want to make something similliar to friend list, so I used self
> referencing HABTM - users_users.
>
> The tables are:
> users (id, friend_id, bla bla bla)     - pk (id, friend_id)      //
> and id of course == friend_id
> users_users (user_id, friend_id)            - pk (user_id, friend_id)
>
> The model relation is:
>         var $hasAndBelongsToMany = array(
>                 'Friend' =>
>                         array('className' => 'User',
>                                         'joinTable' => 'users_users',
>                                         'foreignKey' => 'user_id',
>                                         'associationForeignKey' => 
> 'friend_id',
>                                         'conditions' => '',
>                                         'fields' => '',
>                                         'order' => '',
>                                         'limit' => '',
>                                         'offset' => '',
>                                         'unique' => true,
>                                         'finderQuery' => '',
>                                         'deleteQuery' => '',
>                                         'insertQuery' => ''
>                 ),
>         );
>
> Now I need a controller method (action): function addfriend($friend_id
> = null)
> In body of this action is something like this:
>
> $this->data['User']['id'] = $this->obAuth->getUserId();      //
> retrive the id of logged users
> $this->data['Friend'][0]['friend_id'] = $friend_id;                //
> add the id of friend
> if ($this->User->save($this->data)) {
>         $this->Session->setFlash('Added to Friends.');
>
> }
>
> And it shows me the flash, but I don't see any new records in
> users_users in DB :( Any ideas? Please help me!

Have a look at what you would get in your data if you used a select
box. You want $this->data['Friend']['Friend']['friend_id']

hth,

AD


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