The following kludge did the trick:

The key was to figure out which model to go through for the findAll(),
and which relationship to redefine as hasOne so it will be included in
the query.

Here is the snippet fyi:

// Redefine Order <-> OrderProduct relationship to get Order included
in the query.

$this->Order-> unbindModel(array('hasMany' =>
array('OrderProduct' )));
$this->Order-> bindModel(array('hasOne' => array('OrderProduct' )));

// Specify the group condition using the Account.group_id instead of
Group.id, so we don't need the Group model

$where = "OrderProduct.from_date >= '".$fromDate."' AND
OrderProduct.to_date <= '".$toDate."' AND Account.group_id = '3' ";

// Zero level of recursion should suffice to get the OrderProduct
model included, now that it is hasOne. We can start from the Order
model and the Account model will be included through the Order
belongsTo Account.

$data = $this->Order->findAll($where,null,null,null,null, 0);
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to