On 9/25/06, johnvv <[EMAIL PROTECTED]> wrote:

I'm just getting started with CakePHP and would like to know if it can
handle compound keys in a database.
For example, if you were to add tags to a blog, the schema would
roughly be
table: article(article_id, article_text, PRIMARY_KEY(article_id));
table: tag (tag_id, tag_word, PRIMARY_KEY(tag_id));

Now if you want to associate tags with an article, there would be
another table:
article_tag(article_id, tag_id, PRIMARY_KEY(article_id, tag_id));


You can do this with a join table and a "hasAndBelongsToMany" relationship in your models.

See the model chapter, section 4 for some details and code examples for setting this up.

http://manual.cakephp.org/chapter/models

It is one of the more difficult relationships to get working smoothly so once you try to implement it in you app post back with any problems and someone can help you out with the specifics.



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

Reply via email to