I am trying to save a HABTM, but when i do a save, cake inserts 3
rows. If you could please help me, I would be most grateful because I
am under somewhat of a time constraint:

teams_users

team_id |       user_id
--------------------------------------
0               |       0
74              |       0
1               |       0

1 is my user_id and 74 is my team id. Here is my team_controller:

function create() {

                $this->set("title","Create a New Team");

                if( !empty($this->data) ) {

                        $success = false;
                        $this->Team->create($this->data);

                        if($this->Team->validates() && 
($this->Team->save(array("name"=>
$this->data['Team']['name'],"captain_id"=>$this->Auth->user("id")))))
{

                                $team_id = $this->Team->getLastInsertId();
                                $this->data['Team']['team_id'] = $team_id;
                                $this->data['Team']['user_id'] = 
$this->Auth->user("id");
                                $this->Team->User->save($this->data);
                                $success = true;

                        }



        }


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