Saturday, May 2, 2009

Re: 1 model for multiple database tables

I do not think you can handle more than one table in each model, but
somebody will correct me if I am wrong!

What I don't understand is why you have three tables with the same
content, just to separate team posts and group posts from ordinary
posts! Change your data model into this:

Topic hasMany Post
Post belongsTo Topic
Team hasAndBelongsToMany Topic
Team hasAndBelongsToMany Post
Group hasAndBelongsToMany Topic
Group hasAndBelongsToMany Post

Thus you will only have one model for each and will be able to handle
all the posts from the same model.
Enjoy,
John

On May 2, 11:06 pm, Miles J <mileswjohn...@gmail.com> wrote:
> So I am building a forum system, that will be used for multiple areas.
> The table structure is as follows.
>
> posts
> posts_teams
> posts_groups
> topics
> topics_teams
> topics_groups
>
> For example, all the posts tables are identical, except for the fact
> that posts_teams is only teams posts, and posts_groups is only for
> groups.
>
> I want to be able to use only ONE model (posts) that can manipulate
> all 3 tables. Since they are all the same data and structure, I don't
> want to have duplicate a single model 3 times. Is there a method for
> this already, or a behavior?
>
> If not I think ill go ahead and develop one.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: