Hey Felipe,
If I understand you correctly, whenever you retrieve data about a
MailList Model you would like to only grab the "Active" Email Models
along with it.
I think it is possible in defining your HABTM relationship to set
conditions such as:
"status = 'Active'"
i.e. var $hasAndBelongsToMany = array (
'Email' => array (
'class' => 'Email',
'conditions' => 'status = \'Active\''
)
);
check this against the manual as I'm a little bit slow on this
particular Sunday but I think you should be right. You can also do a
similar thing with the bindModel() function to set these kind of
conditions / relationships on the fly.
Hope this helps,
freedom
On 02/09/06, Felipe Nascimento <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I have the following model objects:
>
> MailList hasManyAndBelongsTo Email
>
> The Email object has an "active" boolean attribute. In the page that
> shows the details of a MailList and wanted to list only the active
> Emails of that MailList.
>
> If I use MailList::read(null, $id), then I get all Emails in the
> resulting query. How is a good way to solve this? Do I need to write a
> specific SQL query and use query() to get only the active Emails from
> a MailList?? Or is there a MailList->someMethod() that I can use?
>
> Tks
> Felipe
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---