开发者

Cakephp retrieve data in HABTM association

开发者 https://www.devze.com 2023-01-17 07:09 出处:网络
I have 2 tables subscribers and distribution list and the relationship between them is HABTM. Now here particular users are associated to distribution list, i wish to add more users, but when adding n

I have 2 tables subscribers and distribution list and the relationship between them is HABTM. Now here particular users are associated to distribution list, i wish to add more users, but when adding new users to distribution list, i would like to show users who are not associated with that di开发者_StackOverflow社区stribution lists. what condition should i write


$this->DistributionSubscriber->find('list', array('conditions'=>array('distribution_id <>' => 1), 'fields'=>array('subscriber_id'), 'recursive'=>-1));

I would try something like this. You want to start with the join table in this case, and do your find() from there. I haven't checked this syntax, but you should get the idea.

0

精彩评论

暂无评论...
验证码 换一张
取 消