It seems eager loading is causing some odd SQL to be used, or I'm doing it wrong. :-)
Here are my models associations:
User: var $has_many = array(
'ideas' => array('class_name' => 'Idea', 'foreign_key' => 'author_id'),
'solutions' => array('class_name' => 'Idea', 'foreign_key' => 'implementor_id'),
'votes' => array('foreign_key' => 'voter_id', 'include' => 'ideas') // this INCLUDE causes the issue.
);
Vote: var $belongs_to = array(
'level',
'idea',
'user' => array('class_name' => 'User', 'primary_key_name' => 'voter_id')
);
Idea: var $belongs_to = array(
'author' => array('class_name' => 'User', 'primary_key_name' => 'author_id'),
'implementor' => array('class_name' => 'User', 'primary_key_name' => 'implementor_id')
);
var $has_many = 'votes';
My goal: Whenever 'votes' are loaded, I want the 'idea' that the vote belongs to loaded too.
Thanks so much!
Yup, works great now! Thanks again Kaste. Now I'm gunna go study what you changed. :-0
1 to 3 of 3