You could use the Model class' bindModel() method to change the
hasMany condition on the fly. In your case, you must use an option
like this: 'conditions' => array('Subscription.active' => TRUE).
I don't know exactly what is your subscriptions table structure. Then,
you should change the field 'Subscription.active' for the correct one.
An example is showed below:
$this->Member->bindModel(array('hasMany' => array('Subscription' =>
array('conditions' => array('Subscription.active' => TRUE)))), FALSE);
$members = $this->Member->find('all');
On Feb 24, 5:40 am, heohni <heidi.anselstet...@consultingteam.de>
wrote:
> Hi,
>
> I have a Member model with hasMany Subscriptions.
>
> Now, in another controller, I am calling the Member Model to give me
> some data.
> I want now to create a find() which lists me all active members with
> their active subscriptions.
>
> Getting the active Members is easy, as this information is stored
> within the members table.
> But how can I get now only the active subscriptions for this
> particular member?
>
> When I call $members = $this->Member->find('all');
> Cake performs 2 statements.
> 1. to get all member results
> 2. to get all subscription results
>
> To get only active members I can set conditions within the find ()
> method.
> But how can I access the 2. query conditions which is selecting the
> subscription results?
>
> Please advise, thanks in advance!
--
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:
Post a Comment