I have just added a var $belongsTo to my 'Prompt' model, so that it
now looks like this:
<?php
class Prompt extends AppModel
{
var $name = 'Prompt';
var $hasMany = array(
'Choice' =>
array('className' => 'Choice',
'conditions' => '',
'order' => '',
'limit' => '',
'foreignKey' => 'preceding_prompt_id',
'dependent' => true,
'exclusive' => true,
'finderQuery' => '',
'fields' => '',
'offset' => '',
'counterQuery' => '')
);
var $belongsTo = array(
'Trade' =>
array('className' => 'Trade',
'conditions' => '',
'order' => '',
'foreignKey' => 'trade_id')
);
}
?>
When I try to pull back a record using this model, I get this error:
Query: SELECT `Prompt`.`id`, `Prompt`.`content`, `Prompt`.`job_id`,
`Prompt`.`trade_id`, `Trade`.`id`, `Trade`.`trade_type` FROM `prompts`
AS `Prompt` LEFT JOIN `trades` AS `Trade` ON (`Prompt`.`trade_id` =
`Trade`.`id`) WHERE id = 450 LIMIT 1
Warning: SQL Error: 1052: Column 'id' in where clause is ambiguous in
C:\Inetpub\wwwroot\cake\cake\libs\model\datasources\dbo_source.php on
line 440
This indicates that MySQL has been given the where clause 'WHERE id =
450', which is producing a ambiguous clause error since the column
name 'id' is in both tables.
In CakePHP you are SUPPOSED to call the primary key in every table
'id'. So why on earth is CakePHP not qualifiying the ID in the where
clause to 'WHERE 'Prompt'.'id' = 450' ??
Can anyone suggest a resolution to this problem?
Thanks
David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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?hl=en
-~----------~----~----~----~------~----~------~--~---