-
☆ A M B ☆
- 427 Posts
I would look into getObjectGraph, getCollectionGraph
Btw, your code is flawed:
public function prepareQueryBeforeCount(xPDOQuery $c) {
$subquery = $xpdo->newQuery('scComment');
$subquery->select(array('
student_assignment_id,
user_id,
comment,
MAX(date_created) AS `comment_date`
'));
$subquery->groupby('student_assignment_id');
$subquery->innerJoin('scComment', 'LatestComments', array (
'scStudentAssignment.id = LatestComments.student_assignment_id'
));
return $subquery;
}
See if that will work. I changed the $c from the docs to $subquery to match your newQuery Object.
Thanks for that Shawn! I was on the road when I responded and was quickly trying to do the function from memory. I've made the corrections to the function in my post above.
getObjectGraph and getCollectionGraph would work great but isn't the function prepareQueryBeforeCount expected to return an xPDOQuery object? Is there really no way to leftJoin a subquery on an xPDOQuery object AND return that xPDOQuery object back to the processor?