Cakephp hasmany, belongsto associations help needed?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

The easiest way to implement this is to use a lookup or join table. Cake uses a so-called "Has And Belongs To Many" (HABTM) relationship for these cases, which is a "many to many" relationship type.

Up vote 1 down vote favorite share g+ share fb share tw.

I am not sure how to proceed for my database schema and for my model associations, any help will be appreciated! Okei, here it goes; Model 1 : Post (id, title, category_id, tag_id, body, created, modified) Model 2 : Category (id, title, description, created, modified) Model 3 : Tag (id, title, description, created, modified) Mu problem is how to "build" the database table to allow for multiple tags and categories, with associations. Example: If Post 1 belongsTo category_id = 1, and hasMany Tag, tag_id: 1, 3, 8, 99 Example2: If Post 2 belongTo category_id = 1,5 and hasMany Tag, tag_id: 1, 8, 43 So basicly, I am not sure what schema to go with and the best practice to allow for multiple associations.

Any suggestions? Thanks! -Tom cakephp model associations habtm link|improve this question asked Feb 2 at 13:10Tom617 75% accept rate.

The easiest way to implement this is to use a lookup or join table. Cake uses a so-called "Has And Belongs To Many" (HABTM) relationship for these cases, which is a "many to many" relationship type. Have a look at the manual entry for HABTM to deal with this kind of scenario.

The manual mentions a comparable setup you're aiming for. In your case you would have posts and tags tables, which are joined by a lookup table called posts_tags containing post_id and tag_id columns. If you define the HABTM relation correctly in your Post Model, Cake will know how to use the three tables correctly when saving, finding and updating data.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions