Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorsuthern
     

    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!

    • CommentAuthorKaste
     

    Fixed in the trunk hopefully with rev #1023. Please update your lib. See my unit-test.

    • CommentAuthorsuthern
     

    Yup, works great now! Thanks again Kaste. Now I'm gunna go study what you changed. :-0