What you are asking for is possible but I would suggest rethinking how you have your tables laid out and also consider how your data should relate to each other. The original meaning of a HABTM table (matches_teams) is meant to be only a joining table. It should really contain only match_id and team_id. From what I can gather from your email is teams can play multiple matches, matches have many teams. However that said match has a score. Personally I would place the score in its own table and possibly relate the score table to a match and also relate it to a team. Similar to the below.
Scores
- id
- match_id
- team_id
- score
On Fri, Jan 4, 2013 at 9:21 AM, marcus33cz <marcus33cz@gmail.com> wrote:
Hiya,I'm wondering if this is possible - imagine you have these tables:teams (id, name)matches (id, date_started, created, modified)matches_teams (id, match_id, team_id)Every team can participate in many matches (e.g. on monday Detroit vs L.A., on wednesday Detroit vs Boston, on saturday Boston vs Tampa Bay)...Can I somehow add more details to the association? I'd like to save how many goals the team scored. So for example Detroit scored 5 goals on monday and 1 goal on wednesday.I believe the best place to store this would be the matches_teams table where you would create another column called score.But do you make sure that this works automagically? How can you set the value of goals in forms (and somehow bind it to the model)?Thanks a lot. :-)--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment