I currently find my latest events using the following:
$conditions = array(
'OR'=>array('Cause.is_active'=>1,
'Event.parent_model'=>'EventOrganiser'),
'Event.datetime_published <='=>date('Y-m-d H:i:s'),
'Event.datetime_starts >='=>date('Y-m-d H:i:s')
);
$contain = array('Cause','CauseOrganisation');
$result = $this->find('all', array(
'conditions'=>$conditions,
'order' => array(
'Event.datetime_starts' => 'ASC',
'Event.datetime_published' => 'DESC'
),
'contain' => $contain
));
This finds all events created by Causes and those special events
created by EventOrganisers.
I am then implementing some content filters to limit events by region
and category and have used the bindModel/find logic shown at:
http://teknoid.wordpress.com/2008/08/06/habtm-and-join-trickery-with-cakephp/
So when filters are active my code changes to:
if ($filters['ContentFilter']['status'] == 1) {
$this->bindModel(array('hasOne'=>array(
'CausesClassificationWhat'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array('CausesClassificationWhat.cause_id =
Cause.id', 'CausesClassificationWhat.option_id'=>$categories)
)
)));
$conditions = array(
'OR'=>array(
array('Cause.is_active'=>1, 'Cause.region_id'=>$regions),
array('Event.parent_model'=>'EventOrganiser')
),
'Event.datetime_published <='=>date('Y-m-d H:i:s'),
'Event.datetime_starts >='=>date('Y-m-d H:i:s')
);
$contain[] = 'CausesClassificationWhat';
}
The problem here is I only get events created by Causes as those
created by EventOrganisers do not INNER JOIN to
CausesClassificationWhat.
Any ideas how I structure my find to allow me to find all events which
match my Cause OR EventOrganiser criteria?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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?hl=en
-~----------~----~----~----~------~----~------~--~---