Tuesday, May 22, 2012

HABTM deep conditions

Hi everybody. Need help with a problem that drives me crazy:)

Suppose you have those model relations:

Offer HABTM Category

How would you build the find conditions to find all the categories
that have at least one offer. In the same time the Offer should be
Offer.enabled => 1. So find all the categories with at least one
enabled offer. The conditions to check in the offer model are several,
but once I can check for the enabled, I think I will be able to check
for any other field.

I could bind the habtm model to Category, but in this case I can't
check the Offer.enabled condition. Maybe somehow using containable?

I have the normal sql query, which I could use but I want to learn how
to do this in the cakephp way

Thank you

--
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: