Hi,
I have Venues HasMany Events association. In the side bar, I want to list only Venues with at least one event associated. What's the find condition?
Hi,
I have Venues HasMany Events association. In the side bar, I want to list only Venues with at least one event associated. What's the find condition?
Cut & Paste from the manual ( http://book.cakephp.org/view/74/Complex-Find-Conditions ):
array('fields'=>array('DISTINCT (User.name) AS my_column_name'), 'order'=>array('User.id DESC'));
You could do this from the events end to find active venues.
Or you could use counterCache to automatically track the number of events for each venue. Then just use Containable and make sure the conditions on the Venue checks for event_count > 0 in the find call.