Thanks for the response.

The groups_units association is needed because there are units that
don't belong to any department but only to groups.

I assume the example you gave is for cake 1.2 ? I am using 1.1 and
can't find that Set::extract in the API. I will try and figure out how
to do this in 1.1, unless someone can offer help with the 1.1
equivalent.

Also, what would be the best place to put this code assuming I want
every Unit to have the full list of unique groups once the Unit model
is read from the database?

Thanks.


On Mar 4, 2:06 am, "Grant Cox" <[EMAIL PROTECTED]> wrote:
> Well, I would scrap the groups_units HABTM association, as it isn't
> really a direct association.  You can't add/remove those associations
> directly, so it's really just a symptom of the main Group ->
> Department -> Units association.
>
> Now, to get the associated group ids from a unit, have something like:
>
> $this->Unit->recursive = 2; // get the Departments, and the
> Departments' Groups
> $unit = $this->Unit->read(null, $unit_id);
> $group_ids = Set::extract($unit, 'Department.{n}.Group.{n}.id';
> $unique_group_ids = array_keys(array_flip($group_ids));


--~--~---------~--~----~------------~-------~--~----~
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