:) Hey... I've find a way to include extra data in a join table...
What I'm doing is to manipulate many tables at once...I mean I simple
need to create a function in a controller... My controller can use
more than one model... So I obtain...
Here's the code
function add()
{
if (!empty($this->data))
{
//We can save the Post data:
//it should be in $this->data['Post']
$this->set('members', $this->Member->save($this->data));
$this->set('addresses', $this->Address->save($this->data));
//Now, we'll need to save the Comment data
//But first, we need to know the ID for the
//Post we just saved...
$member_id = $this->Member->getLastInsertId();
//Now we add this information to the save data
//and save the comment.
$this->data['Memberrole']['member_id'] = $member_id;
$this->data['Contact']['member_id'] = $member_id;
//Because our Post hasMany Comments, we can access
//the Comment model through the Post model:
$this->set('contacts', $this->Contact->save($this-
>data));
$this->set('memberroles', $this->Memberrole->save($this-
>data));
$contact_id = $this->Contact->getLastInsertId();
$address_id = $this->Address->getLastInsertId();
$this->data['Contactaddress']['contact_id'] = $contact_id;
$this->data['Contactaddress']['address_id'] = $address_id;
$this->set('contactaddresseses', $this->Contactaddress-
>save($this->data));
}
}
Simply concentrate on the first piece of code.....
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---