On Jun 9, 3:45 pm, Matthew Dunham <[email protected]> wrote:
> Ok my models are as follows:
>
> Product HABTM Tags (with products_tags table)
> Tag belongsTo TagGroup
>
> Can some help me work out the following problem I'm having: How can I
> get all tags for a certain product ID, along with their Tag Group?
If you're not already, use ContainableBehavior. Personally, I include
it in my AppModel as I use it quite a lot. A basic example:
$data = $this->Product->find(
'first',
'conditions' => array(
'Product.id' => $id
),
'fields' => array(...),
'contain' => array(
'Tag' => array(
'TagGroup'
)
)
);
Also, if you want to fetch all products by a particular tag, have a
look at this article by Nate:
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find
I'm not sure how you would incorporate this to get the TagGroup,
though, but I'd guess that could be done.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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