Email 获取HABTM关系中的数据,使用Cake'格式化和发送数据;s邮件组件
也许这是一个简单的问题,但我不知道如何解决它。 我在Email 获取HABTM关系中的数据,使用Cake'格式化和发送数据;s邮件组件,email,cakephp,has-and-belongs-to-many,opml,Email,Cakephp,Has And Belongs To Many,Opml,也许这是一个简单的问题,但我不知道如何解决它。 我在播客和用户及其在CakePHP 2.3.6中的基本烘焙应用程序之间有一种HABTM关系。 用户可以“订阅”播客 我想 获取当前登录用户的所有播客 使用CakePHP emailcomponent将文件(.opml,XML格式)发送到当前登录用户的电子邮件,该组件包含特定格式的播客表字段 1。获取所有播客:这就是我所拥有的。 debug($this->viewVars)显示数组为false。。为什么? Model/Podcast.php Use
播客
和用户
及其在CakePHP 2.3.6
中的基本烘焙应用程序之间有一种HABTM关系。
用户可以“订阅”播客
我想
1。获取所有播客:这就是我所拥有的。
debug($this->viewVars)
显示数组为false
。。为什么?
Model/Podcast.php
UsersController.php
2。发送文件
仅仅是一个基本的想法或方法将非常有用 CakeEmail在这里有很好的文档记录,包括示例、解释……等等:
public function getPodcastsByUserId($userId = null) {
if(empty($userId)) return false;
$podcasts = $this->find('all', array(
'joins' => array(
array('table' => 'podcasts_users',
'alias' => 'PodcastsUser',
'type' => 'INNER',
'conditions' => array(
'PodcastsUser.user_id' => $userId,
'PodcastsUser.podcast_id = Podcast.id'
)
)
),
'group' => 'Podcast.id'
));
return $podcasts;
}
public function showMyPodcasts() {
$userId = $this->Session->read('Auth.User.Id');
$this->loadModel('Podcast');
$podcasts = $this->Podcast->getPodcastsByUserId($userId);
$this->set('podcasts', $podcasts);
}