try like this
$this->paginate = array(
'conditions' => array('Game.time !=' => NULL, 'Game.visible' =>
1, 'Game.end_time !=' => NULL, 'Game.moves !=' => NULL),
'group' => array('Game.uid'),
'order' => array('Game.time' => 'DESC'),
'limit' => 3
);
On Wed, Nov 7, 2012 at 11:01 PM, Ivan Švaljek <[email protected]>wrote:
> Hi, I'm having trouble with sorting during pagination. I'm trying to list
> users with lowest solvetime, but order key in paginate method doesn't seem
> to like order field if it's a result of aggregate function like MIN().
>
> This is my action:
>
> public function index() {
> $this->paginate = array(
> 'fields' => array('*, MIN(Game.time AS mintime'),
> 'conditions' => array('Game.time IS NOT NULL AND Game.visible
> = 1 AND Game.end_time IS NOT NULL AND Game.moves IS NOT NULL'),
> 'order' => array('mintime' => 'ASC'),
> 'group' => array('Game.uid'),
> 'limit' => 3
> );
> $games = $this->paginate('Game');
>
> $this->set('games', $games);
> }
>
> ...it doesn't even add an ORDER BY clause in the debug. If some other
> field is set as order argument it works.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
--
*Ivan Rimac***
mail: [email protected]
*tel: +385 95 555 99 66*
*http://ivanrimac.com*
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.