Monday, September 29, 2008

Containable Behaviour

I am trying out the Containable behaviour but am not getting the
correct result (or at least my expected result!).

I have a DealerAddress model (for their head office) which is
associated to a DealerBranchAddress model (for their branch address)
and I want to be able to return all dealers in a specific region. This
needs to be whether their head office or their branch office is in
that region.

So I have tried the following:

$this->DealerAddress->find('all',
array('conditions'=>array('DealerAddress.region_id'=>64), 'contain' =>
array('DealerBranchAddress'=>array('conditions'=>array('DealerBranchAddress.region_id'=>64))))));

That doesn't return the correct result as it seems to be appending an
AND clause to the query
which I can see in the debug output as "SELECT blah.... WHERE
`DealerBranchAddress`.`region_id` = 64 AND
`DealerBranchAddress`.`dealer_id` = (3)".

I want it to be (pseudo code): find all DealerAddress and
DealerBranchAddress where region_id=64

Which should return all my dealer addresses, whether it's their head
or branch office, in region 64.

Any help would be good thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: