Hi Everyone,

This problem is kind of complicated but I'll try to explain it as best
I can.

I have a model/database table: Games
The games table has a `home_team_id` field and a `visiting_team_id`
field. These are both set up as belongsTo (HomeTeam and AwayTeam) in
the associations with the model as Team.

In addition it has a `home_score` field and a `visiting_score` field.
Based on which of these fields is greater, I determine a virtual field
`winning_team_id` which is equal to either the `home_team_id` or
`visiting_team_id`.

What I'd like to do is set up another belongsTo named WinningTeam with
a foreign key of `winning_team_id`. However, I can't do this because
`winning_team_id` is a virtual field. So what I want to do is to
manually set the WinningTeam:

$this->WinningTeam = Team::findById($this->winning_team_id);

Where do I put this (and what are the edits I need to make to the
statement)? I want the WinningTeam variable to be accessible on ALL
Game models so that in any of my controllers I could do something like
$this->Game->WinningTeam.

I hope that's clear; I'd be glad to clarify anything. Thanks so much
for the help.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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