I currently have a query that results in the following set of records:
Array ( [Contestant] => Array ( [id] => 1 [name] => test [age] => [city] => atest [telephone] => [email] => test@test.com [why_model_house] => a [highschool] => [photo] => 5329_119145013633_512383633_2487923_7196193_n0.jpg [active] => 1 ) [0] => Array ( [Contestant_votes] => 4 ) [Vote] => Array ( [id] => 1 ) )
I can get paginator-> sorting to work with any data in it, except for "Contestant_votes", since it does not belong to the model that is currently in the array [0]
I tried to do this:
<th><?php echo $paginator->sort('Votes', '0.Contestant_votes'); ?></th>
and this:
<th><?php echo $paginator->sort('Votes', 'Contestant_votes'); ?></th>
But that will not work. The conestants_votes field is generated by the following request:
'Contestant.*, count(Vote.contestant_id) as Contestant_votes'
So why is this not in the model. Is there a way to trick cakephp into thinking that Contestant_votes is part of the Contestant model or a way to add it to a paginator so that I can sort it?
Thanks in advance,
Fabian Brenes
source
share