Say we have a posts and tags table and the HABTM association has been
set with posts_tags as the join_table. I am able to save the tags to
the database. My problem is I know which posts belong to which user
through the posts table

posts:
-----
id, user_id, title, details

tags:
------
id, name

posts_tags
-------------
id, post_id, tag_id


What I want to do, is that when user wants to post a new post, I want
to show the tags that belongsTo the posts that have been made by user
and not all the tags. In the posts controller, if I do $this->Post-
>Tag->generateList() gives me the full list of all tags and I do not
want this. Moreover, the sql statement issued for this is :

SELECT `Tag`.`id`, `Tag`.`name` FROM `tags` AS `Tag` WHERE 1 = 1

Should I use $this->Post->findAll(array('Post.user_id'=>$userid)); and
then fetch the tags from here but does not seem optimal way to do it.
Please suggest me better solution.

Thanks
Ketan


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