Thanks for the reply cakeFreak, I check out all 3 links and I think I understand it. However I cannot seem to get it to save. If I try to add a friend to a user that has an account in the system it doesn't seem to work, it yields a warning.
Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE/cake/libs/model/model.php, line 1674] It is having problems saving the newly constructed $this->data. Below is my add_friends function function addfriend($friend_id = null) { // $this->data = $this->User->read(array('id'), $this- >obAuth->getUserId()); //let us try and add friends for the user with id=3 $this->data = $this->User->read(array('*'), '3'); //view user's info print_r($this->data['User']); $friends = array(); foreach ($this->data['Friend'] as $friend) { $friends[] = $friend['id']; } $friends[] = $friend_id; echo "<br>friend array:"; print_r($friends); $admirers = array(); foreach ($this->data['Admirer'] as $admirer) { $admirers[] = $admirer['id']; } $admirers[] = $friend_id; echo "<br>admirer array:"; print_r($admirers); unset($this->data['Friend']); unset($this->data['Admirer']); $this->data['Friend']['Friend'] = $friends; $this->data['Admirer']['Admirer'] = $admirers; echo "<br>printing this->data:"; print_r($this->data); echo "<div> did it save?: ".$this->User->save($this->data)."</ div>"; /* if ($this->User->save($this->data)) { $this->Session->setFlash('Added to Friends.'); } */ } Also, do I need to populate the friend_id in the users table with anything? such as the user_id? or just blank. Below is the schema of my users table. id friend_id group_id firstname astname email password active On Oct 3, 6:08 pm, cakeFreak <[EMAIL PROTECTED]> wrote: > Try to read these posts: > > Self-referential has_many :through > associationshttp://blog.hasmanythrough.com/2006/4/21/self-referential-through > > http://groups.google.com/group/cake-php/browse_frm/thread/c8ebc2097f8... > > http://groups.google.com/group/cake-php/browse_frm/thread/e70d4147be0... > > Hope this helps! > > Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---