Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthoradityamooley
    • CommentTimeAug 18th 2007 edited
     

    I am trying to associate my post model with comments model by writing

    var $has_many = 'comments';
    

    in posts model.

    Now, when I write $this->Post->find($id); it only fetches the post for the given id and not the comments for that post. I saw the query and its only

    SELECT * FROM posts WHERE posts.id = 1 LIMIT 1
    

    No join condition in the above query.

  1.  

    After debugging more into this I found that I have to pass the associated class name to the find() function. But now its giving following error message:

    Fatal error: Class 'Comment' not found in /home/****/akelos/lib/AkActiveRecord/AkHasMany.php on line 617
    

    Looks like the comment model file is not getting included before instantiation. The line causing this error is:

    $ModelInstance =& new $class_name();
    

    in file AkHasMany.php

    •  
      CommentAuthoradityamooley
    • CommentTimeAug 18th 2007 edited
     

    OK. Fixed the problem. I added a line

    require_once(AKInflector::toModelFilename($class_name));
    

    or more appropriately

    Ak::import($class_name);
    

    just above

    $ModelInstance =& new $class_name();
    

    in file AkHasMany.php

    I have submitted a patch for this file

Add your comments
    Username Password
  • Format comments as