hi I'm new to fuel, I've searched for an answer everywhere but can't find it.
There are orm models named Comment and Comments_Vote, the problem is to extract each comment with it's corresponding votes (each row in comments_votes table being 1 vote). This is what I have so far:
<code>
$comments = Model_Comment::find('all', array(
'related' => array(
'comments_vote' => array(
'select' => array('sum(vote)'),
),
),
'order_by' => array('date' => 'desc'),
));
</code>
As you can see I'm trying to apply a select to the related model, and using MySQL function SUM to sum all the rows that have a vote in place.
I've also tried it with chaining:
<code>
$comments = Model_Comment::find()
->related('comments_vote')
->select('sum(vote)')
->get();
</code>
The error that shows on both is basically an SQL query saying that the 'vote' column can't be found, by looking directly at the query it's because it's looking for 'vote' in comments table, instead of comments_vote table.
Maybe it's not possible to use 'Select' in related models,only conditionals or am I doing something wrong?