[EMAIL PROTECTED] wrote:
> I'm not sure what's wrong with using $hasOne in the Judge model. If a
> Judge MUST be linked to a specific person, and only one person, $hasOne
> seems to be the way to do it.
I actually tried that, i.e., added a $hasOne = 'person' to my Judge
model. Then I defined an index action in my JudgesController class:
function index()
{
$this->pageTitle = 'Judge test';
$this->set('judges',$this->Judge->findAll());
}
and wrote a quick and dirty view:
foreach ($judges as $j) { pr($j,true);}
and when I accessed it in a browser I got this debug info:
Query: SELECT `Judge`.`person_id`, `Judge`.`location_id`,
`Judge`.`flavor`, `Person`.`id`, `Person`.`lastname`,
`Person`.`firstname` FROM `judges` AS `Judge` LEFT JOIN `people` AS
`Person` ON `Person`.`judge_id` = `Judge`.`id` WHERE 1 = 1
Error: 1054: Unknown column 'Person.judge_id' in 'on clause'
which makes sense, I guess. Cake expects the person table to have a
column called judge_id, because that's what I told it. My problem is
that it's the other way around: 'judges' has a column called person_id
>
> Is your concern that a Person might not have an associated Judge model
> (e.g, they have a different job)?
Exactly! Thank you for stating it more concisely than I did.
Clearly, I shouldn't start putting columns judge_id, janitor_id, etc in
my people table.
I have started experimenting with instantiating a person object in my
judge constructor and writing my own query->("SELECT ...") to get what
I want, but whenever things start looking complicated I start to
suspect I am on the wrong track.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---