Hey All,
I'm sorry if this has already been covered somewhere, but I can only find usage examples for relational AR where the findAll() method is being called without any conditions applied. Is there a way to use a conditional find method, like findAllByAttributes(), with relational AR where conditions are placed on the relational tables? Assuming that my model relationships are set up correctly, I'd like to do something like:
$posts = Post::model()->with('comment','comment.author')->findAllByAttribute( array( 'post_id'=>5, 'comment.author'=>array('author_id'=>2), ) );
In other words, for this example I'm trying to get all posts with their comments and comment authors where the post id is 5 and the author id is 2. Using findAll() would be fine, too, as long as relational conditions could be specified in a CDbCriteria object and passed into the findAll() method.
Is something like this possible with AR? Thanks in advance.