Another solution might be (don't know how elegant this is) to add a
finderQuery in your HABTM-relation. Just copy the present habtm-query
(you'll see it with debug level 2, for example), modify it a bit and
add it to your models habtm-statement. In your case the modification
should be something like this: in the SELECT-section add
"posts_tags"."tag_link_id" AS "Tag__tag_link_id" and than modify the
tag_id the JOIN's ON-section to be a magical {$__cakeID__$} and than
your habtm-query should return the tag_link_id in the associated Tag-
model.

As I said, I don't know how elegant this approach is, but it worked
for me :)

On Feb 21, 6:41 am, mason <[EMAIL PROTECTED]> wrote:
> Hello all, got a question that I haven't yet seen an answer to...
>
> I have a fairly standard many:many relationship, much like the classic
> Posts-Tags example. I have the standard join table, with an extra
> column, for example:
>
> posts (id, text)
> tags (id, name)
> posts_tags (post_id, tag_id, tag_link_id)
>
> So this is where it gets unorthodox. Using the standard
> hasAndBelongsToMany, when I'm iterating a list of posts I can easily
> enough get the tags. But does anyone have a suggestion for *also*
> getting the tag_link_id for the association?
>
> As an example, I'd like to take a Post, and iterate its array of Tags.
> For each Tag, I want to get Tag.name but also get the tag_link_id from
> the corresponding row in posts_tags. I suppose I could do a find in
> posts_tags using the post_id and tag_id, but that's an extra database
> query for data that I should already have.
>
> Any suggestions of a clever way to carry this associated data along?
>
> Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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