asprin
Active member
I've two tables:
A TO_MANY relationship is defined on FC:Teams where FC:Teams can have multiple FC:Members.
Now if I want to use the finder system to fetch all rows from FC:Teams but order DESC by number of members present in it, how would I go about it?
Something like this:
There is the option of using raw SQL query to fetch the data, but then I'll lose the in-built pagination feature used on the finder object (
Is this achievable?
|
|
A TO_MANY relationship is defined on FC:Teams where FC:Teams can have multiple FC:Members.
Now if I want to use the finder system to fetch all rows from FC:Teams but order DESC by number of members present in it, how would I go about it?
Something like this:
PHP:
$finder = $this->finder('FC:Teams')->setDefaultOrder('<count of members in the team>', 'DESC');
return $finder;
There is the option of using raw SQL query to fetch the data, but then I'll lose the in-built pagination feature used on the finder object (
limitByPage()
) and I'll have to take care of all the offsets, page numbers etc.Is this achievable?