Hey,
I want to build a list of Countries with their id's as valueto
populate a select-box. The problem is that I have a condition and have
to go over 3 models to get my information. Here are the relations of
my models:
Shop->Location->Country.
I want to find every country where the corresponding Shop is active.
So I figuered that I could search for all Shops which are active and
get the countries over their locations, and after that I want to group
them and order them alphabetically so i can populate a select with the
result.
Here's my approach so far but it won't work:
$this->Shop->find('all', array(
'contain' => array(
'Location.Country'),
'conditions' => array(
'Shop.active' => 1),
'group' => 'Country.name'
));
Shop belongsTo Location, and Location belongsTo Country.
The find I'm doing (eventually not exactly the one above, but I tried
many constellations) returns the Shops which are active and their
Countries, but a i mentioned I need the Countries to be listet for my
select.
I could just go through my result with foreach and build up an array
manually to do this, but I think there has to be a better way by
directly finding my information with a more precise find-call.
I'd be happy if anyone could give me a hint on this one!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---