Thursday, March 31, 2011

delete a join record

I have two models: Team and Season, these are binded by Membership
model. As explained in book, i've designed it as:
Team and Season hasMany Membership
Membership belongsTo Season and Team

If I want create a membership row:

function add($season_id, $team_id)
{
if(($this->Season->exist($season_id) && $this->Team-
>exist($team_id)))
{
$data = array('Membership' =>array('season_id' =>
$season_id, 'team_id' => $team_id));
if($this->save($data))
{
return 1;
}
}
return 0;
}

he table memberships contain just two foreign key (season_id and
team_id).
What now if I would remove a row from memberships passing the 2
foreign key?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: