Cakephp 删除HABTM关系的联接表中的记录

Cakephp 删除HABTM关系的联接表中的记录,cakephp,has-and-belongs-to-many,Cakephp,Has And Belongs To Many,关系如下所示: Podcasts <-HABTM-> Users UserController.php public function removePodcast($podcastId, $userId){ if(empty($podcastId) || empty($userId)) return false; $this->User->PodcastsUser->deleteAll(array( 'PodcastsUser.p

关系如下所示:

Podcasts <-HABTM-> Users
UserController.php

public function removePodcast($podcastId, $userId){
    if(empty($podcastId) || empty($userId)) return false;

    $this->User->PodcastsUser->deleteAll(array(
        'PodcastsUser.podcast_id' => $this->data['Podcast'][$podcastId], 
        'PodcastsUser.user_id' => $this->data['Podcast'][$userId]
    ));
}
public function removepodcast($podcastId, $userId){
    //$this->loadModel('PodcastsUser');
    $this->User = ClassRegistry::init('PodcastsUser');

    if ($this->User->removePodcast($podcastId, $userId)){
        $this->Session->setFlash(__('The podcast has been removed'));
        $this->redirect(array('controller' => 'users', 'action' => 'index'));
    }else {
            $this->Session->setFlash(__('The podcast could not be removed. Please, try again.'));
        }
}
查看/用户/

echo $this->Html->link(__('Remove'), array('controller' => 'users', 'action' => 'removepodcast', $mypodcast['Podcast']['id'], $this->Session->read('Auth.User.id')));
我看了这个,但我不清楚。
请帮我举个例子或改正,我将不胜感激

您只需要在UserController上调用此函数$此->用户->删除播客();我现在添加了更多代码谢谢,现在有什么问题?任何错误?是:
未定义索引:Podcast[APP/Model/PodcastsUser.php
该Podcast已作为flash消息删除。感谢您的帮助在模型函数中将$this->data['Podcast'][$podcastId]替换为podcastId,将$this->data['Podcast'][$userId]替换为$userId]