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.
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
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
1 to 3 of 3