Are you using Cake to define model associations?

Looks to me like:
Post hasAndBelongsToMany Category
Category hasAndBelongsToMany Post

So tables would look like:

posts
- id
- title
- body

categories
- id
- name 
- desc

categories_posts (HABTM tables are plural of both models, in alphabetical order)
post_id
category_id

Check out http://manual.cakephp.org/chapter/6, especially the "Defining and Querying with hasAndBelongsToMany" section for more info.

-- John

On May 9, 2006, at 1:36 PM, eDevil wrote:
<snipped>
Here's my situation. I have some tables in mysql (posts, comments,
categories, post_category etc). I am able to add/edit/delete posts and
categories but I cant associate posts with the categories. I need to
have a list of categories with checkboxes on my Add Posts form so that
I can categorize my posts.

This is pretty complex and there's no way I could get this working on
cake but i'm sure its possible.
Here's my database structure:

posts
 - id
 - title
 - body

categories
 - id
 - name
 - desc

post_category
 - post_id
 - category_id
 FOREIGN KEY (post_id) REFERENCES posts (id),
 FOREIGN KEY (category_id) REFERENCES categories (id)

Now how do I get these 3 tables connected?

Thanks in advance.
Azad



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

Reply via email to